ADSI = Active Directory Service Interfaces - Active Directory と通信して Active Directory にユーザー、グループ、コンピュータ アカウントを作成するための API です。これは、Microsoft ネットワーク用のネットワーク ベースの LDAP ディレクトリです。
では、ローカル マシン/サーバーにローカル ユーザーを作成する必要がありますか?それとも、Active Directory にグループを作成する必要がありますか??
.NET 3.5 以降でプログラミングしている場合は、System.DirectoryServices.AccountManagement
(S.DS.AM) 名前空間を調べてください。ここでそれについてすべて読んでください:
基本的に、ドメイン コンテキストを定義し、AD でユーザーやグループを簡単に見つけることができます。
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
// do something here....
}
// create a group
GroupPrincipal group = new GroupPrincipal(ctx, "Group01");
// set other properties on the group here.....
group.Save();
新しい S.DS.AM を使用すると、AD でユーザーやグループを簡単に操作できます。
更新:残念ながら、新しい S.DS.AM はローカル グループでは機能しません :-( Active Directory での使用のみを目的としています。
ローカル Windows グループを作成する必要がある場合は、次のDirectoryEntry
ような古いアプローチを使用する必要があります。
// bind to your machine's WinNT:// provider
DirectoryEntry computer = new DirectoryEntry("WinNT://YourMachineNameHere");
// create a new local group on your computer
DirectoryEntry newGroup = computer.Children.Add("NewGroupName", "Group");
// save that group to the local machine
newGroup.CommitChanges();
// refresh the property cache so you can set properties like "Description" or others
newGroup.RefreshCache();
newGroup.Properties["description"].Value = "Description for your group....";
newGroup.CommitChanges();
Richard Mueller は、LDAP ベースの Active Directory オブジェクトと非常に限定された WinNT プロパティの両方で利用可能なさまざまなプロパティをすべて示すExcel シートの優れたリストを持っています。