How can I get the local group name for guests/administrators?

后端 未结 5 822
死守一世寂寞
死守一世寂寞 2020-12-29 08:21

Question:

I use the code found at http://support.microsoft.com/kb/306273

to add a windows user. The problem is i need to add the user to a group, but the gro

5条回答
  •  余生分开走
    2020-12-29 08:59

    This page has some code for getting user details and checking them.

    This code:

    public IdentityReferenceCollection GetUserGroups()
    {
        System.Security.Principal.WindowsIdentity currentUser =
                          System.Security.Principal.WindowsIdentity.GetCurrent();
        return currentUser.Groups;
    }
    

    returns the current user's groups.

    More details on the WindowsIdentityclass as a whole can be found here, with the Groups property here.

提交回复
热议问题