111,094
社区成员




public void ReadLdapUser(string ipAddress, string ldapUsername, string ldapPassword)
{
string subpathformat = "LDAP://{0}/o=sdf";
string subpath = String.Format(subpathformat, ipAddress);
DirectoryEntry entry = new DirectoryEntry(subpath,ldapUsername,ldapPassword);
entry.AuthenticationType = AuthenticationTypes.Anonymous;
DirectorySearcher mySearcher = new DirectorySearcher(entry);
foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
DirectoryEntry de = resEnt.GetDirectoryEntry();
if (de.Properties.Count >= 20)
{
foreach (string elmentName in de.Properties.PropertyNames)
{
PropertyValueCollection valueCollection = de.Properties[elmentName];//这里一遇到扩展属性的名字一读就报异常,{"未知错误(0x8000500c)"}
for (int i = 0; i < valueCollection.Count; i++)
{
string kkk = valueCollection[i].ToString();
MessageBox.Show(kkk);
}
}
if (de.SchemaClassName.ToString() == "inetOrgPerson")
{
string userGuid = Guid.NewGuid().ToString();
}
}
}
}