如何使用的objectGUID得到一个DirectoryEntry? [英] How to use the objectGUID get a DirectoryEntry?

查看:897
本文介绍了如何使用的objectGUID得到一个DirectoryEntry?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我们可以得到这样一个DirectoryEntry:

I know ,we can get a DirectoryEntry like this:

string conPath = "LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com";
string conUser = "administrator";
string conPwd = "Iampassword";
DirectoryEntry de = new DirectoryEntry(conPath, conUser, conPwd, AuthenticationTypes.Secure);

和我们可以改变用户的口令是这样的:

and we can change a user's password like this:

DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = String.Format("sAMAccountName={0}", "xumai");
SearchResultCollection results = deSearch.FindAll();
foreach (SearchResult objResult in results)
{
    DirectoryEntry obj = objResult.GetDirectoryEntry();
    obj.Invoke("setPassword", new object[] { "Welcome99" });
    obj.CommitChanges();
}

如果使用

string x = obj.Guid.ToString();;

我们可以得到用户的的objectGUID0b118130-2a6f-48d0-9b66-c12a0c71d892

we can get the user's objectGUID "0b118130-2a6f-48d0-9b66-c12a0c71d892"

如何更改密码就是这个基地的objectGUID?

how can i change it is password base this objectGUID ?

如何搜索用户群这个的objectGUID形式的LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com?

how to search the user base this objectGUID form "LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com"?

有没有办法筛选吗?等strFilter的=(及(的objectGUID = 0b118130-2a6f-48d0-9b66-c12a0c71d892));

is there any way filter it ? etc strFilter = "(&(objectGUID=0b118130-2a6f-48d0-9b66-c12a0c71d892))";

希望对你有所帮助。

感谢。

推荐答案

在不改变你code你得的多种方式绑定到活动目录。这里有两个其他方式:

Without changing you code you've got multiple way to bind to Active-Directory. Here are two others ways :

第一个使用GUID绑定对象

string conPath = "LDAP://10.0.0.6/<GUID=0b118130-2a6f-48d0-9b66-c12a0c71d892>";

第二个使用SID绑定到对象

string conPath = "LDAP://10.0.0.6/<SID=S-X-X-XX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXX-XXX>"; 

使用安全主体你可以做这样的:

UserPrincipal user = UserPrincipal.FindByIdentity(adPrincipalContext, IdentityType.DistinguishedName,"CN=User1Acct,OU=TechWriters,DC=wds,DC=gaga,DC=com");

UserPrincipal user = UserPrincipal.FindByIdentity(adPrincipalContext, IdentityType.Guid,"0b118130-2a6f-48d0-9b66-c12a0c71d892");

这篇关于如何使用的objectGUID得到一个DirectoryEntry?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆