Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pretty slick, huh? (No!)

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
overflow
LXF regular


Joined: Tue Aug 23, 2005 2:40 pm
Posts: 158
Location: London

PostPosted: Tue Sep 13, 2005 6:44 pm    Post subject: Pretty slick, huh? (No!) Reply with quote

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:
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:
grep "^kenmyer:" /etc/passwd


Which is slicker, Script Guy?
_________________
overflow
Back to top
View user's profile Send private message
M0PHP
LXF regular


Joined: Wed Apr 06, 2005 8:40 am
Posts: 737
Location: Bishop Auckland, County Durham, UK

PostPosted: Tue Sep 13, 2005 7:59 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8450
Location: Warrington, UK

PostPosted: Tue Sep 13, 2005 9:14 pm    Post subject: Reply with quote

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


although it's even easier with

Code:
id -u kenmyer


Smile
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast