morla
(Lurker)
2006-06-23 05:12 PM
list of local user profiles

helloe all,
i'm new to kixtart, so i'll post my question here... first of all
kixtart rock's like hell!!!

so now to my question,
is it possibel to get a list of all 'local user profiles'(sorry for my bad english) that are located/installed on a client machine???

how would u code that?? is there a macro or something?

any help would be appreciated

thx
i <3 kixtart


Les
(KiX Master)
2006-06-23 05:20 PM
Re: list of local user profiles

You can find it in the reg.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList


morla
(Lurker)
2006-06-23 05:23 PM
Re: list of local user profiles

cool man!!! thats great!
hmm.. i'm relativly new to windows OS, how can i learn more about the registry?

^i'll try that now...


morla
(Lurker)
2006-06-23 05:41 PM
Re: list of local user profiles

hmm.. ok. i had a look in the registry...
under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
there are alot strange numbers (hrm. i guess kind of sid or so...)
i'd like to just extrackt the userid or the name of the users that have a local profile...
how do i work myselfe through al the folders under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
????

i have no clue...
thank u in advance


LonkeroAdministrator
(KiX Master Guru)
2006-06-23 07:28 PM
Re: list of local user profiles

with enumkey and some looping.

but, you won't get no userID or username from there.
you will only get the profile folder (which is some sorta construct of the userID though)


Howard Bullock
(KiX Supporter)
2006-06-23 07:51 PM
Re: list of local user profiles

Once you enumerate the keys (sids) under ProfileList, pass them to SidToName() for a translation to domain\user format.

NTDOCAdministrator
(KiX Master)
2006-06-23 09:05 PM
Re: list of local user profiles

You could also try running something like this to see all the names of the profiles.

Dim $ProL,$PL,$Tmp,$DV
$ProL = ExpandEnvironmentVars(ReadValue('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList','ProfilesDirectory'))
$PL = Dir($ProL)
While $PL <>'' And @ERROR = 0
If $PL
If Not InStr($PL,'.') And Not InStr($PL,'..')
$PL ?
EndIf
EndIf
$PL = Dir()
Loop


Les
(KiX Master)
2006-06-23 09:36 PM
Re: list of local user profiles

That is just a list of folders. Not necessarily proper profiles as per what is listed in the reg.

LonkeroAdministrator
(KiX Master Guru)
2006-06-23 10:17 PM
Re: list of local user profiles

hmm...
the sidtoname sounds actually the simpliest way to go...


NTDOCAdministrator
(KiX Master)
2006-06-23 11:59 PM
Re: list of local user profiles

True, but sort of depends on what you want the information for I suppose.  I've seen folders there that are not in the registry too (probably due to some tech messing with it, or poorly behaved app)

LonkeroAdministrator
(KiX Master Guru)
2006-06-24 12:25 AM
Re: list of local user profiles

or just simply broken profile or reinstalled windows or...
if it's not in the registry, it does not matter to windows as it is not a profile dir.
on the other hand, it can have some personal information in it.
for data retrieval purposes, those folders may hold some meaning.


NTDOCAdministrator
(KiX Master)
2006-06-24 01:00 AM
Re: list of local user profiles

Okay, round 2. Is this better?

Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')

Dim $BaseKey,$DataKey,$UserID
Dim $ArrayBaseKey,$Key,$Profile
Dim $DataSid,$ProfileSID
$BaseKey = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\'
$DataKey = 'ProfileImagePath'
$DataSid = 'Sid'
$ArrayBaseKey = ArrayEnumKey($BaseKey)
For Each $Key In $ArrayBaseKey
If $Key
$Profile = Split(ReadValue($BaseKey+$Key,$DataKey),'\')[2]
$ProfileSID = ReadValue($BaseKey+$Key,$DataSid)
'SID2Name: ' SidToName($Key) ?
'Registry Account Name: ' + $Profile ?
'SID: ' + $Key ?
'SID (REG value): ' + $ProfileSID ??
EndIf
Next

Function ArrayEnumValue($regsubkey)
Dim $retcode, $valuecounter, $currentvalue, $valuearray
If Not KeyExist($regsubkey)
Exit 87
EndIf
$valuecounter=0
Do
$currentvalue=EnumValue($regsubkey,$valuecounter)
If Not @ERROR
ReDim PreServe $valuearray[$valuecounter]
$valuearray[$valuecounter]=$currentvalue
$valuecounter=$valuecounter+1
EndIf
Until @ERROR
$arrayenumvalue=$valuearray
Exit 0
EndFunction

Function arrayenumkey($regsubkey)
Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
If Not KeyExist($regsubkey)
Exit 87
EndIf
$subkeycounter=0
Do
$currentsubkey=EnumKey($regsubkey,$subkeycounter)
If Not @ERROR
ReDim PreServe $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
EndIf
Until @ERROR
$arrayenumkey=$subkeyarray
Exit 0
EndFunction



Howard Bullock
(KiX Supporter)
2006-06-24 02:39 AM
Re: list of local user profiles

Doc, did you test that? All you need to do is take the text Sid (name of profilelist subney) and pass that to SidToNAme().

[edit] After a re-read, it looks good. [/edit]


NTDOCAdministrator
(KiX Master)
2006-06-24 02:43 AM
Re: list of local user profiles

Yes I tested it. The SID that it returns from the REG is some other format and NOT the SID required to show it from KiXtart conversion. I just wanted to go ahead and display that too, but I suppose it could be confusing as it's not the same.

It returns 3 formats. Like this...

Code:
Registry Account Name: LocalService
SID2Name: LOCAL SERVICE
Account SID: 010100000000000513000000



Did YOU run it

Give it a try and you should see it works just fine.


Howard Bullock
(KiX Supporter)
2006-06-24 02:44 AM
Re: list of local user profiles

Yeah, that sid is in Hex format.

NTDOCAdministrator
(KiX Master)
2006-06-24 02:49 AM
Re: list of local user profiles

Okay, updated the code above a little. Here is sample output.


Code:
SID2Name: LOCAL SERVICE
Registry Account Name: LocalService
SID: S-1-5-19
SID (REG value): 010100000000000513000000



LonkeroAdministrator
(KiX Master Guru)
2006-06-24 03:38 AM
Re: list of local user profiles

what does "registry account name" mean?

NTDOCAdministrator
(KiX Master)
2006-06-24 04:14 AM
Re: list of local user profiles

Well if we look at the code we see that it reads this from the registry ProfileImagePath which typically is just the FOLDER name.

SidToName on the otherhand also gives the Domain the account comes from.


JOHNDOE
 vs.
SOMEDOMAIN\JOHNDOE
 


LonkeroAdministrator
(KiX Master Guru)
2006-06-24 04:53 AM
Re: list of local user profiles

but...
looking at the code, it would not always return "JOHNDOE"
sometimes it will also return "JOHNDOE.SOMEDOMAIN" or "JOHNDOE.SOMEDO~1" or something alike.


NTDOCAdministrator
(KiX Master)
2006-06-24 06:56 AM
Re: list of local user profiles

Only if it's in the Registry which would be a VALID profile whether or not it was from corruption or whatever.

Not sure what your point is Jooel. This is just an exercise in showing various ways of getting the data requested.

I don't see any "specifics" of include/exclude requirements, or even a reply since I posted this code except from us regulars.

If / When such stringent requirements are provided then he can hopefully have at least an idea of how to constrain the data to his requirements, which is better than just generalizations on how to do it.