yes, but its not a very good check if you want to determine if they have admin rights, unless something has changed lately you have to attempt to write a value to a root reg hive.
check the IsMember method
there should be posts in the KeyWord search on the subject
Set User = GetObject("WinNT://" & strComputer & "/" & strUserName & ",user")
Set Group = GetObject("WinNT://" & strComputer & "/Administrators,group")
Msgbox Group.IsMember(User.ADsPath)
it be faster to just get the User object and iterate through the groups
Set User = GetObject("WinNT://" & strComputer & "/" & strUserName & ",user")
For Each aGroup In User.Groups
If LCase(aGroup.Name) = "administrators" Then
Msgbox "yes they are"
End If
Next
or, it might be quicker to just use the group
Set Group = GetObject("WinNT://" & strComputer & "/Administrators,group")
For Each aMember In Group.Members
If aMember.Name = strUserName Then
Msgbox "they are"
End If
Next
all depends on your taste and if you prefer to only bind to one object, but i think i stretch the point
you have to bind to the local computer using something the WinNT provider, loop through all the local groups checking if the user is a member of one of them, then act on it if required
I did that and was able to display all local groups that a domain user belongs to. How do you display domain group users within my local group. Here's my script:
Set oWshNet = CreateObject("WScript.Network")
StrUserID = InputBox("Enter UserID")
Const FOR_READING = 1
StrFilename = "c:\scripts\host.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFilename, FOR_READING)
Do Until objFile.AtEndofStream
StrComputer = objFile.ReadLine
Wscript.Echo "Server:" & StrComputer
Wscript.Echo ""
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each oGroup In colGroups
For Each oUser in oGroup.Members
' Check if user is a local user
If InStr(1, oUser.ADsPath, "/" & sComputer & "/", vbTextCompare) > 0 Then
If oUser.Name = StrUserID Then
Wscript.Echo vbTab & "Local Group:" & oGroup.Name
End If
End If
Next
Next
Loop
objFile.Close
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.