实现C# LDAP用户身份验证,在线等,解决问题立马结贴,谢谢!

解决方案 »

  1.   

    string str = "LDAP://yourserver/CN=username,CN=users,DC=yourdnsname,DC=CN";
    DirectoryEntry de = new DirectoryEntry( str , @"yourdnsname\"+struser ,strpwd , 
      AuthenticationTypes.SeverBinder );
    try
    {
       string guid = de.Guid.ToString();
      return true;
    }
    catch
    {
       return false;
    }
      

  2.   

    凭记忆写的,有可能有错,具体的查一下msdn 的System.DirectoryServices
      

  3.   

    我现在出现的问题是空密码就可以成功,一旦有密码就不行,是怎么回事
    ========
    AuthenticationTypes.SeverBinder );
      

  4.   

    string path = "LDAP://192.168.95.250:389/cn=user1,ou=groupoffice,dc=bdhg,dc=cn";
    string username = "user1";
    string domainAndUsername = domain + @"\" + username;DirectoryEntry entry = new DirectoryEntry(path,domainAndUsername, pwd, AuthenticationTypes.ServerBind);说是无效DN用下面这种方法有密码就不行
    string path = "LDAP://192.168.95.250:389/ou=groupoffice,dc=bdhg,dc=cn";
    string username = "user1";
    DirectoryEntry entry = new DirectoryEntry(path,username, pwd, AuthenticationTypes.ServerBind);