我有一个代码,它给我一个在Active Directory中更改的用户列表。它使用DirSync控件。当我选择获取完整的属性列表时,我只收到以下内容:
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: user
whencreated: 20141202165637.0Z
name: gfdgfgfd
objectsid: System.Byte[]
countrycode: 0
primarygroupid: 513
samaccounttype: 805306368
useraccountcontrol: 66048
pwdlastset: 130620129983259471
parentguid: System.Byte[]
codepage: 0
objectcategory: CN=Person,CN=Schema,CN=Configuration,DC=test,DC=com
userprincipalname: gfdgdf@test.com
displayname: gfdgfgfd
accountexpires: 9223372036854775807
ntsecuritydescriptor: System.Byte[]
givenname: gfdgfgfd
instancetype: 4
samaccountname: gfdgdf
objectguid: System.Byte[]
我还要得到尊贵的名字。是否可能
这是我的代码:
string str_dcName = "xxxxxxxx";
System.DirectoryServices.DirectoryEntry rootDSE = new System.DirectoryServices.DirectoryEntry("LDAP://rootDSE");
System.Net.NetworkCredential cr = new System.Net.NetworkCredential(@"User", "Pass", "test.com");
LdapConnection connection = new LdapConnection(str_dcName);
connection.Credential = cr;
connection.Bind();
SearchRequest request = new SearchRequest("DC=test,DC=com", "(|(objectClass=organizationalUnit)(isDeleted=TRUE)(objectClass=user)(objectcategory=person))", SearchScope.Subtree, null);
DirSyncRequestControl dirSyncRC = new DirSyncRequestControl(cookie, DirectorySynchronizationOptions.IncrementalValues, Int32.MaxValue);
request.Controls.Add(dirSyncRC);
bool bMoreData = true;
SearchResponse searchResponse = (SearchResponse)connection.SendRequest(request);
谢谢!
答案 0 :(得分:2)
所以杰出的名字不在属性之内。
while (bMoreData)
foreach (SearchResultEntry entry in searchResponse.Entries)
Console.WriteLine(entry.DistinguishedName);