Jump to content

GetAccountSid Function


Recommended Posts

Hey Guys -

I am attempting to use the GetAccountSid Function to get the SID of the machine, but I can only get it to return 0. Any ideas? Here is the code I have so far for testing. The help file documentation isn't real helpful. I'm not sure if it has to be an array or something?

#Include <Security.au3>

$sAccount = @UserName

$sSystem = ""

$SID = _Security__GetAccountSid($sAccount, $sSystem = "")

MsgBox(4096, "Test", $SID)

Thanks in advance.

Edited by Tbird800
Link to comment
Share on other sites

_Security_GetAccountSid() returns a binary value in byte structure which isn't easy to work with. Try using _Security_LookupAccountName() instead, then use the index (zero) of the array and it will give you the SID in string format.

#Include <Security.au3>
$sAccount = @UserName
$SID = _Security__LookupAccountName($sAccount)
MsgBox(4096, "Test", $SID[0])
Edited by Airwolf
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Thanks! Worked great. I was writing some code to remove saved Internet Explorer passwords as well as prevent any more from being saved in the future. This is what I came up with:

If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "DisablePasswordCaching") = 0 and @OSVersion = "WIN_XP" THEN

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "DisablePasswordCaching", "reg_dword", "1")

$sAccount = @UserName

$SID = _Security__LookupAccountName($sAccount)

FileCopy(@AppDataDir & "\Microsoft\Credentials\" & $SID[0] & "\*.*", @AppDataDir & "\Microsoft\Credentials\")

FileDelete(@AppDataDir & "\Microsoft\Credentials\" & $SID[0] & "\*.*")

EndIf

Maybe this will help someone else.

Thanks again.

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...