[英]C# Active Directory DirSync. Is it possible to get distinguished name attribute?
I have a code that gives me a list of Users changed in Active Directory. 我有一个代码,可以为我提供在Active Directory中更改的用户列表。 It uses DirSync Control. 它使用DirSync控件。 When I choose to get the full list of attributes I receive only the following: 当我选择获取属性的完整列表时,只会收到以下内容:
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[]
I need to get also the distinguished name. 我还需要获得专有名称。 Is it possible 可能吗
This is my code: 这是我的代码:
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);
Thanks! 谢谢!
OK, after a while I discovered that I was missing something. 好吧,过了一会儿,我发现我丢失了一些东西。 In SearchResponse all the entries have: 在SearchResponse中,所有条目都具有:
So Distinguished name is not inside of the attributes. 因此,专有名称不在属性内。
while (bMoreData)
foreach (SearchResultEntry entry in searchResponse.Entries)
Console.WriteLine(entry.DistinguishedName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.