Jump to content

Recommended Posts

Posted

I have a problem where I'm trying to set one particular setting for PuTTY, specifically, turn on X Forwarding in the default settings. The setting is stored in the registry, but of course, not under HKCU, no it's under HKey_Users\{SID} ... So to set it, I have to find out the users SID and then I can write to it via RegWrite...

Any ideas? Or even a better way to set PUTTY default settings?

Posted

by wmi

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Posted

I guess to be more specific - how do I do that? There is no WMI in the AutoIT Help. How do I get the SID into my AutoIT script as a variable so I can do the RegWrite described?

Posted

From 'Hey, Scripting Guy!': How Can I Determine the SID for a User Account?

The linked solution is in Visual Basic Script, but can be used in AutoIT if you have learned AutoIt's COM/OBJ functions.

Let the help file reading begin!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

IIRC, you can only write to the current user's registry anyway. If you're thinking of changing the setting for more than one user, 'fraid that won't work even if you know the SID because the hives in question aren't loaded until the owner logs-on.

OTOH, for the logged-on user, HKCU is all you need.

Posted (edited)

IIRC, you can only write to the current user's registry anyway. If you're thinking of changing the setting for more than one user, 'fraid that won't work even if you know the SID because the hives in question aren't loaded until the owner logs-on.

OTOH, for the logged-on user, HKCU is all you need.

You can write to another user's registry, providing you have the needed admin privileges. Each user's hive is actually NTUser.dat in their profile directory. The link to that hive in RegEdit under HKU (which is displayed by SID) is just a link to the NTUser.dat in their profile. But the only easy way to read/write to NTUser.dat for another user is via the registry link at HKU\{SID}. BTW, you'll want that setting in HKU\.DEFAULT so it is included automatically for new users, who just get a copy of .DEFAULT's NTUser.dat in their profile the first time they logon.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

I have a problem where I'm trying to set one particular setting for PuTTY, specifically, turn on X Forwarding in the default settings. The setting is stored in the registry, but of course, not under HKCU, no it's under HKey_Users\{SID} ... So to set it, I have to find out the users SID and then I can write to it via RegWrite...

Any ideas? Or even a better way to set PUTTY default settings?

If you don't feel like reinventing the wheel, grab a copy of Auto3Lib from my signature and run this:

#include <A3LSecurity.au3>

Opt("MustDeclareVars", 1)

Global $sUser, $aName

$sUser = InputBox("Security Demo", "Enter Network Name:", "Administrator", "", 200, 130)
if @Error <> 0 then Exit

$aName = _Security_LookupAccountName($sUser)
if @Error = 0 then
  _Lib_ConsoleWrite("SID .........: " & $aName[0]                      )
  _Lib_ConsoleWrite("Domain ......: " & $aName[1]                      )
  _Lib_ConsoleWrite("SID Type ....: " & _Security_SidTypeStr($aName[2]))
else
  _Lib_ConsoleWrite("Invalid user name")
endif
Auto3Lib: A library of over 1200 functions for AutoIt
Posted

hi Paul

i've just thought about your library

tsss i use this for sid why did i not mention it

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Posted

Thanks all, but I found a better way for my purposes - which is I noticed that PuTTY has a command line switch for this ... I feel stupid, but it's doing what I need.

  • 7 months later...
Posted

Incase anyone is interested I built a function to do this.

Func _getSID($username, $domain, $servername = ".")

Local $objWMIService = ObjGet("winmgmts:\\" & $servername & "\root\cimv2")

Local $security = $objWMIService.Security_

$security.ImpersonationLevel = 3

Local $objAccount = $objWMIService.Get("Win32_UserAccount.Name='" & $username & "',Domain='" & $domain & "'")

Return $objAccount.SID

EndFunc

$SID = _getSID("administrator", "TESTDOMAIN")

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
  • Recently Browsing   0 members

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