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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -