检查用户名

时间:2018-01-28 14:43:56

标签: c# authentication login ldap

我有一个登录页面,我需要用户通过检查用户名来登录而不知道用户所在的域名。

 String adPath = "LDAP://domain";
 LdapAuthentication adAuth = new LdapAuthentication(adPath);
 if (true == adAuth.IsAuthenticated(domain, username, Password))
 { 
  // something to do
 }

如何根据用户动态更改域路径?

1 个答案:

答案 0 :(得分:1)

添加条件以在检查用户名

后更改adAuth
 string adPath = "LDAP://domain";
 string anotheradPath = "LDAP://seconddomain";

 if (username== "something" )
    {
        adAuth = new LdapAuthentication(adPath );
    }
 else
    {
         adAuth = new LdapAuthentication(anotheradPath );
    }