Code Project で次のサンプルを見つけました。これは、DirectoryServices を使用して新しいユーザーを追加する方法を示しています。
private void AddUser(string strDoamin, string strLogin, string strPwd)
{
DirectoryEntry obDirEntry = null;
try
{
obDirEntry = new DirectoryEntry("WinNT://" + strDoamin);
DirectoryEntries entries = obDirEntry.Children;
DirectoryEntry obUser = entries.Add(strLogin, "User");
obUser.Properties["FullName"].Add("Amigo");
object obRet = obUser.Invoke("SetPassword", strPwd);
obUser.CommitChanges();
}
catch (Exception ex)
{
Trace.Warn(ex.Message);
}
}
しかし、私がSafari Books Onlineにサインアップし、そこで "The .NET Developer's Guide to Directory Services Programming" (ISBN 10: 0-321-35017-0; ISBN 13: 978-0-321-35017-6
この本は、ディレクトリ サービスのプログラミングの基本をすべて説明し、ユーザーの追加、アクセス許可の設定などの具体的な例を示しているため、私のジレンマに合わせて作成されているようです。