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

后端 未结 5 811
死守一世寂寞
死守一世寂寞 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:56

    You should be able to use the WindowsIdentity and WindowsPrincipal classes:

    Dim currentIdentity as WindowsIdentity = WindowsIdentity.GetCurrent()
    Dim currentPrincipal as WindowsPrincipal = New WindowsPrincipal(currentIdentity)
    
    If currentPrincipal.IsInRole(WindowsBuiltInRole.Guest) Then
       Foobar()
    End If
    

    Nevermind, I see you were actually trying to ADD a user to the group.

提交回复
热议问题