1

While enumerating members of local group of server remotely, I am getting error because of unresolved sids. Is there any work around skip such group members.

    PrincipalContext dt = new PrincipalContext(ContextType.Machine, server1);
    string account=grupname.Text;
    GroupPrincipal ga = GroupPrincipal.FindByIdentity(dt, account);
    userlist = new List<string>();


    var users = ga.GetMembers();


    try
        {
            //exception generated here   
          foreach (Principal user in users)
         {
         userlist.Add(user.SamAccountName.ToString());
         }

        }

    catch (System.DirectoryServices.AccountManagement.PrincipalOperationException ent)
    {
        MessageBox.Show(ent.Message.ToString());

    }


         Userlistview.Items.Clear();
    foreach (string s in userlist)
    {
        Userlistview.Items.Add(s);
    }

Please suggest how to bypass users where "Error occurred while resolving sid" exception can be skipped.

Sandeep K
  • 163
  • 2
  • 13

0 Answers0