Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LDAP Support for the new Authentication System in VS2013 (based on owin (owin.org) )

Do we know how to implement LDAP support for the new authentication system introduced in VS 2013 which is based on owin.org .

I have written my own provider using Forms authentication but it doesnt work any more.

Any ways to extend this will also be highly welcome. All I see is built in support for a lot of oauth providers like Google, Twitter and Facebook.

like image 447
Kunal Deo Avatar asked Jul 16 '13 08:07

Kunal Deo


1 Answers

It's actually pretty easy. You simply need to override the CheckPasswordAsync method in the provided UserManager. (Full disclosure, that's my blog post).

public class ApplicationUserManager : UserManager<ApplicationUser> {
//...SNIP...
    public override async Task<bool> CheckPasswordAsync(ApplicationUser user, string password)
    {
        return await Task.Run(() => {
            _context = new PrincipalContext(ContextType.Domain);
            return _context.ValidateCredentials(user.UserName, password, ContextOptions.Negotiate)
        });
    }
}

That's a very naiive method, but it should work.

like image 80
Michael Dunlap Avatar answered Nov 15 '22 01:11

Michael Dunlap