事前定義された Active Directory グループにコンピューター名を追加する必要があるという要件があります。誰もこれに関連した経験がありますか?
3538 次
3 に答える
1
System.DirectoryServices を使用して C# コードでこれを行うことができます。
// Bind to the Computers container and add a new computer.
DirectoryEntry de01 = new DirectoryEntry("LDAP://CN=Computers,DC=fabrikam,DC=com");
DirectoryEntry newComputer = de01.Children.Add("CN=New Computer", "computer");
newGroup.CommitChanges();
例については、 http://msdn.microsoft.com/en-us/library/ms180832 (v=VS.90).aspx を参照してください。
于 2011-03-09T10:15:15.883 に答える
0
以下のコードは私のために働いた
//Step 1: get the DN of the adgroup you want to use
DirectoryEntry groupEntry = new DirectoryEntry ("LDAP://CN=AdgroupNameWewantToAddTo,DC=na,DC=ABCint,DC=com");//adgroupDSN
//step 2: get the Dn of the pc you want to add to the group string memberDN; DirectorySearcher dom = new DirectorySearcher(baseDN); dom.Filter = "(&(ObjectCategory=computer) (cn=" + PCNAME+ "))"; SearchResult searchResult = dom.FindOne(); if (searchResult != null) { memberDN=searchResult.GetDirectoryEntry().Path; }
//ステップ3:PCを広告グループに追加します
groupEntry.Invoke( "Add"、computerdn);
于 2013-01-09T09:23:59.573 に答える
0
ADSI を使用します。基本的に、Active Directory にバインドし、必要なコンピューター オブジェクトとグループ オブジェクトを見つけ、メソッドを呼び出してコンピューターをグループに追加します。
コマンド ラインから実行する必要がある場合は、WSH または .Net を使用して簡単に実行できます。
ADSI リファレンス: http://msdn.microsoft.com/en-us/library/aa772218(v=VS.85).aspx
ADSI LDAP: http://msdn.microsoft.com/en-us/library/aa746384(v=VS.85).aspx
コンピュータが再起動するまで有効になりません。
于 2011-03-09T10:15:50.567 に答える