3

私は知っています、私たちはこのようなDirectoryEntryを得ることができます:

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);

次のようにユーザーのパスワードを変更できます。

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();;

ユーザーのobjectGUID「0b118130-2a6f-48d0-9b66-c12a0c71d892」を取得できます

このobjectGUIDをパスワードベースに変更するにはどうすればよいですか?

このobjectGUIDフォーム「LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com」のユーザーベースを検索する方法は?

それをフィルタリングする方法はありますか?etc strFilter = "(&(objectGUID = 0b118130-2a6f-48d0-9b66-c12a0c71d892))";

あなたの助けを願っています

ありがとう。

4

2 に答える 2

8

コードを変更せずに、Active-Directoryにバインドする複数の方法があります。他に2つの方法があります:

最初のものは、GUIDを使用してオブジェクトにバインドします

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

2つ目は、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");
于 2011-07-12T02:37:38.867 に答える
0

.NET 3.5がオプションの場合は、を使い始める必要がありますSystem.DirectoryServices.AccountManagement。まったく新しい世界です。GUIDでユーザーを検索するコードは次のとおりです。

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, 
                                                  "LDAP://10.0.0.6", 
                                                  "DC=wds,DC=gaga,DC=com", 
                                                  "administrator", 
                                                  "Iampassword"))
{
    string theGuid = "0b118130-2a6f-48d0-9b66-c12a0c71d892";
    UserPrincipal up = UserPrincipal.FindByIdentity(pc, IdentityType.Guid, theGuid);
}

同じテンプレートを他のオブジェクトタイプに簡単に適合させることができます。

于 2011-07-11T14:33:37.220 に答える