Pretty slick, huh? (No!)

Discussion topics, Linux related - not requests for help

Moderators: ChrisThornett, LXF moderators

Pretty slick, huh? (No!)

Postby overflow » Tue Sep 13, 2005 5:44 pm

Unfortunately, in my work, I come into constant contact with Windows, which I find increasingly troublesome. Today, I needed to find out who a SID belonged to. A SID, if you don't know, is a complex string that uniquely identifies a user - globally. A bit like uid numbers in Unix.

Anyway, I needed to find the owner of a SID and so after a bit of a hunt, I came across this on MS TechNet's Script Guy site which, although back-to-front, would allow me to get there.

Technet wrote:
Code: Select all
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='kenmyer',Domain='atl-ws-01'")
Wscript.Echo objAccount.SID

Pretty slick, huh?

No!

Absolutely horrible!.

What a revolting, unmemorable, twisted mess.

Try this:
Code: Select all
grep "^kenmyer:" /etc/passwd


Which is slicker, Script Guy?
overflow
User avatar
overflow
LXF regular
 
Posts: 158
Joined: Tue Aug 23, 2005 1:40 pm
Location: London

Postby M0PHP » Tue Sep 13, 2005 6:59 pm

But you could argue that "Wscript.Echo objAccount.SID" gets the actual SID, whereas the grep command you quoted gets the whole line of the *nix username.
User avatar
M0PHP
LXF regular
 
Posts: 737
Joined: Wed Apr 06, 2005 7:40 am
Location: Bishop Auckland, County Durham, UK

Postby nelz » Tue Sep 13, 2005 8:14 pm

Code: Select all
grep ^kenmyer: /etc/passwd | cut -d: -f3


although it's even easier with

Code: Select all
id -u kenmyer


:-)
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8468
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK


Return to Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests