Jump to content
Sign in to follow this  
brNwsH

current logged in users SID

Recommended Posts

brNwsH

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

Share this post


Link to post
Share on other sites
hannes08

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]

Share this post


Link to post
Share on other sites
brNwsH

i use a registry monitor and it only showed the change in the HKU not in the HKCU :mellow:

but after you mentioned it i took a closer look and the key is written in the HKCU too.

thx

Share this post


Link to post
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
Sign in to follow this  

×