 |
Linux Format forums Help, discussion, magazine feedback and more
|
| View previous topic :: View next topic |
| Author |
Message |
overflow LXF regular

Joined: Tue Aug 23, 2005 2:40 pm Posts: 158 Location: London
|
Posted: Tue Sep 13, 2005 6:44 pm Post subject: Pretty slick, huh? (No!) |
|
|
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 |
|
 |
M0PHP LXF regular

Joined: Wed Apr 06, 2005 8:40 am Posts: 737 Location: Bishop Auckland, County Durham, UK
|
Posted: Tue Sep 13, 2005 7:59 pm Post subject: |
|
|
| 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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 8002 Location: Warrington, UK
|
Posted: Tue Sep 13, 2005 9:14 pm Post subject: |
|
|
| Code: | | grep ^kenmyer: /etc/passwd | cut -d: -f3 |
although it's even easier with
 _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|