Pretty slick, huh? (No!)

Discussion topics, Linux related - not requests for help

Moderators: ChriThor, 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 _
Wscript.Echo objAccount.SID

Pretty slick, huh?


Absolutely horrible!.

What a revolting, unmemorable, twisted mess.

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

Which is slicker, Script Guy?
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.
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)
Site admin
Posts: 8782
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Return to Discussion

Who is online

Users browsing this forum: No registered users and 2 guests