Monday, April 27, 2020

System.DirectoryServices.AccountManagement beyond System.DirectoryServices.ActiveDirectory

using(var ServerContext = new PrincipalContext(ContextType.Domain))
{
   GroupPrincipal outerGroupPrincipal = new GroupPrincipal(ServerContext, alt);
   PrincipalSearcher principalSearcher = new PrincipalSearcher(outerGroupPrincipal);
   foreach (var found in principalSearcher.FindAll())
   {
      GroupPrincipal innerGroupPrincipal = found as GroupPrincipal;
      if (innerGroupPrincipal != null)
      {
         foreach (Principal p in innerGroupPrincipal.GetMembers())
         {
            var hello = "goodbye";
         }
      }
   }
}

No comments:

Post a Comment