Giriş
Şu satırı dahil ederiz.
Açılan PrincipalContext ile grupları sorgulamamızı sağlar.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
using System.DirectoryServices.AccountManagement.
GroupPrincipal;
FindByIdentity metoduAçılan PrincipalContext ile grupları sorgulamamızı sağlar.
Şöyle yaparız.
// find the group in question
GroupPrincipal grp = GroupPrincipal.FindByIdentity(pc, "YourGroupNameHere");
Şöyle yaparız.string grpName = "SL-FILE-DAF-Agriculture-RID-PIFT";
var grp = GroupPrincipal.FindByIdentity(pc, IdentityType.SamAccountName,grpName);
GetMembers metoduŞöyle yaparız.
PrincipalSearchResult<Principal> members = grp.GetMembers(true);
Her grup elemanını şöyle dolaşırız.// iterate over members
foreach (Principal p in group.GetMembers())
{
UserPrincipal up = p as UserPrincipal;
if (up != null)
{
Console.WriteLine("{0}: {1}", p.StructuralObjectClass, p.DisplayName);
// do whatever you need to do with that user principal
}
}
Her bir grup üyesinin hesap ismini şöyle alırız.foreach (var member in members)
{
Console.WriteLine(member.SamAccountName);
}
GetUnderlyingObject metoduŞöyle yaparız.
DirectoryEntry entry = group.GetUnderlyingObject() as DirectoryEntry;
Hiç yorum yok:
Yorum Gönder