Tag: ldap

如何通过LDAP + SSLvalidationActive Directory信誉?

我正在尝试使用.NET 3.5 System.DirectoryServices.AccountManagement命名空间来validation通过SSL加密LDAP连接对我们的Active Directory LDAP服务器的用户凭据。 这是示例代码: using (var pc = new PrincipalContext(ContextType.Domain, “sd.example.com:389”, “DC=sd,DC=example,DC=com”, ContextOptions.Negotiate)) { return pc.ValidateCredentials(_username, _password); } 此代码在不安全的LDAP(端口389)上工作正常,但我宁愿不以明文forms传输用户/传递组合。 但是,当我更改为LDAP + SSL(端口636)时,我得到以下exception: System.DirectoryServices.Protocols.DirectoryOperationException: The server cannot handle directory requests. at System.DirectoryServices.Protocols.ErrorChecking.CheckAndSetLdapError(Int32 error) at System.DirectoryServices.Protocols.LdapSessionOptions.FastConcurrentBind() at System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions) at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password) at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password) at (my code) 端口636适用于其他活动,例如查找该LDAP […]

Active Directory(LDAP) – 检查帐户被锁定/密码已过期

目前,我使用以下代码针对某些AD对用户进行身份validation: DirectoryEntry entry = new DirectoryEntry(_path, username, pwd); try { // Bind to the native AdsObject to force authentication. Object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry) { Filter = “(sAMAccountName=” + username + “)” }; search.PropertiesToLoad.Add(“cn”); SearchResult result = search.FindOne(); if (result == null) { return false; } // Update the new path […]

使用C#根据LDAP对用户进行身份validation

我正在使用DirectorySearcher在LDAP服务器中搜索用户条目。 DirectoryEntry de = new DirectoryEntry(); de.Path = “LDAP://myserver/OU=People,O=mycompany”; de.AuthenticationType = AuthenticationTypes.None; DirectorySearcher deSearch = new DirectorySearcher(); deSearch.SearchRoot = de; deSearch.Filter = “(uid=” + model.UserName + “)”; SearchResult result = deSearch.FindOne(); 我能够在结果变量中得到预期的输出。 但是,如果我尝试通过在目录条目中提供密码来validation同一用户,我总是会遇到以下错误。 “用户名或密码不正确。” DirectoryEntry entry = new DirectoryEntry(“LDAP://myserver/OU=People,O=mycompany”, username, password); DirectorySearcher search = new DirectorySearcher( entry, “(uid=” + username + “)”, new string[] { […]