は、.NET 3.5とアップにしているので、あなたはSystem.DirectoryServices.AccountManagement
(S.DS.AM)名前空間をチェックアウトする必要があります。ここではそれについてのすべてを読む:
を基本的には、ドメインコンテキストを定義し、簡単にADのユーザーおよび/またはグループを見つけることができます。また、GroupPrincipal
には、GetMembers
というメソッドがあり、そのグループのすべてのメンバーがリストされます。オプションで、再帰的に実行されます。
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find the group you're interested in
GroupPrincipal myGroup = GroupPrincipal.FindByIdentity(ctx, "SomeGroup");
// if you found it - get its members
if (myGroup != null)
{
// if your call the GetMembers, you can optionally specify a "Recursive" flag - done here
var allMembers = myGroup.GetMembers(true);
}
新しく追加されたS.DS.AMは、ADのユーザーとグループで本当に簡単に遊べます!
このリンクは役立ちます:http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%94Retrieving_tokenGroups_from_ADAM –