active directory - How can you use asp.net core windows authentication alongside Cookie Authentication? -
i have asp.net core (.net framework 4.7) application using cookie authentication in this link
app.usecookieauthentication(new cookieauthenticationoptions() { authenticationscheme = "cookieauthentication", loginpath = new pathstring("/login/"), accessdeniedpath = new pathstring("/login/"), automaticauthenticate = true, automaticchallenge = true });
what want allow windows authentication cookie authentication. if user in company's domain he/she doesn't have enter user name , password.but if coming external domain redirected login page , enter user name , password authenticated.
if user in company's domain he/she doesn't have enter user name , password.
doesn't have enter user name , password
tricky part. far know, cannot satisfy both authentication at same time.
however, can ask both type of users enter username , password, , authenticate system first. if authentication fails, can authenticate domain account.
if scenario workable, can use novell.directory.ldap in asp.net core. here sample code.
public bool validateuser(string domainname, string username, string password) { string userdn = $"{username}@{domainname}"; try { using (var connection = new ldapconnection {securesocketlayer = false}) { connection.connect(domainname, ldapconnection.default_port); connection.bind(userdn, password); if (connection.bound) return true; } } catch (ldapexception ex) { // log exception } return false; }
note: of today, system.directoryservices not available in asp.net core yet.
Comments
Post a Comment