Tag: active directory

使用C#向Active Directory注册更改通知

此链接http://msdn.microsoft.com/en-us/library/aa772153(VS.85).aspx说: 您可以在单个LDAP连接上注册最多五个通知请求。 您必须有一个专用线程,等待通知并快速处理它们。 当您调用ldap_search_ext函数来注册通知请求时,该函数将返回标识该请求的消息标识符。 然后使用ldap_result函数等待更改通知。 发生更改时,服务器会向您发送一条LDAP消息,其中包含生成通知的通知请求的消息标识符。 这会导致ldap_result函数返回标识更改对象的搜索结果。 通过.NET文档我找不到类似的行为。 如果有人知道如何在C#中做到这一点,我将非常感谢知道。 我希望看到系统中所有用户的属性发生变化,以便我可以根据更改的内容执行自定义操作。 我查看了stackoverflow和其他来源没有运气。 谢谢。

如何通过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#Active Directory:获取用户的域名?

我知道之前曾经问过这类问题,但其他方法现在都让我失望了。 正如我们的Windows服务轮询AD,给定一个LDAP(即LDAP://10.32.16.80)和该AD服务器中要搜索的用户组列表。 它检索这些给定组中的所有用户,以递归方式搜索这些组以获取更多组。 然后将每个用户添加到另一个应用程序认证用户列表中。 这部分应用程序运行成功。 但是,我们需要每个用户的友好域名(即他们登录DOMAIN /用户名的一部分) 因此,如果有一个用户属于TEST域,则名为Steve:TEST / steve是他的登录名。 我能够在AD中找到steve,但是我还需要“TEST”与他的AD信息一起存储。 再一次,我可以通过使用目录搜索器和我给出的LDAP IP找到’史蒂夫’,但是考虑到LDAP IP,我怎样才能找到友好的域名? 当我尝试以下代码时,我在尝试访问’defaultNamingContext’时遇到错误: System.Runtime.InteropServices.COMException(0x8007202A):身份validation机制未知。 这是代码: private string SetCurrentDomain(string server) { string result = string.Empty; try { logger.Debug(“‘SetCurrentDomain’; Instantiating rootDSE LDAP”); DirectoryEntry ldapRoot = new DirectoryEntry(server + “/rootDSE”, username, password); logger.Debug(“‘SetCurrentDomain’; Successfully instantiated rootDSE LDAP”); logger.Debug(“Attempting to retrieve ‘defaultNamingContext’…”); string domain = (string)ldapRoot.Properties[“defaultNamingContext”][0]; //THIS […]

从C#访问AD时“从服务器返回引用”exception

DirectoryEntry oDE = new DirectoryEntry(“LDAP://DC=Test1,DC=Test2,DC=gov,DC=lk”); using (DirectorySearcher ds = new DirectorySearcher(oDE)) { ds.PropertiesToLoad.Add(“name”); ds.PropertiesToLoad.Add(“userPrincipalName”); ds.Filter = “(&(objectClass=user))”; SearchResultCollection results = ds.FindAll(); foreach (SearchResult result in results) { Console.WriteLine(“{0} – {1}”, result.Properties[“name”][0].ToString(), result.Properties[“userPrincipalName”][0].ToString()); } } 在SearchResultCollection results = ds.FindAll(); 我得到一个例外: 从服务器返回了推荐 为什么我会得到那个例外,这是什么意思?

c #Active Directory服务findAll()仅返回1000个条目

可能重复: 我可以从Asp.Net中的DirectorySearcher获取超过1000条记录吗? 我正在使用ADS Directory搜索器findAll()方法搜索现有登录(如下面的代码所示)。 似乎findall方法只返回1000个条目,尽管有更多的条目。 如何查找每次登录的所有()? IList adslist = new List(); using (DirectoryEntry de = new DirectoryEntry(“LDAP://armlink.com”, null, null, AuthenticationTypes.Secure)) using (DirectorySearcher ds = new DirectorySearcher(de, “(objectclass=user)”, new string[] { “samaccountname” })) foreach (SearchResult sr in ds.FindAll()) { string[] e = sr.Path.Split(new string[] { “LDAP://”, “OU=”, “,”, “DC=”, “.com”, “/CN=” }, StringSplitOptions.RemoveEmptyEntries); ResultPropertyCollection pc = […]