繁体   English   中英

C#Active Directory DirSync。 是否可以获取专有名称属性?

[英]C# Active Directory DirSync. Is it possible to get distinguished name attribute?

我有一个代码,可以为我提供在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);

谢谢!

好吧,过了一会儿,我发现我丢失了一些东西。 在SearchResponse中,所有条目都具有:

  • 属性
  • 控制
  • 专有名称

因此,专有名称不在属性内。

while (bMoreData)
   foreach (SearchResultEntry entry in searchResponse.Entries)
      Console.WriteLine(entry.DistinguishedName);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM