Jump to content

current logged in users SID


 Share

Recommended Posts

Hey Com,

i need 2 change a registry key on 200 clients but its unfortunately under HKEY_Users.

so i searched the forum and found some scripts to read the users SID but it doesnt return the right SID

$UserSID = _GetSID()
MsgBox (1, "test", $UserSID)

Func _GetSID($sComputerName = @ComputerName, $sUsername = @UserName)
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!//" & $sComputerName & "/root/cimv2")
    Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_UserAccount")
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            If $sUsername = $oObjectItem.Name Then
                Return $oObjectItem.SID
            EndIf
        Next
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_GetSID

It is returning "S-1-5-21-2929902127-4284358396-3866876256-500"

but my SID in the reg is "S-1-5-21-535800494-807093659-1863580331-500"

so where is the problem.

thx

brN

Link to comment
Share on other sites

Hm... works fine for me. What I can see from your SID is that you've got a completely different DOMAIN/Workstation identifier.

Just a question: why do you want to get the SID of the current user if you could use the "HKCU" reg hive?

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...