#62964 - 2002-02-08 04:04 PM
Display account information
|
Jeroen
Starting to like KiXtart
Registered: 2001-08-16
Posts: 180
Loc: Netherlands
|
Hi,I'm looking for a way to display account information of a useraccount I specify in the domain. I probably need ADSI to do this? The info I need would be the Fullname and the Comment, output like: Account: jvdvlier Fullname: Johan van der Vlier Comment: Sales Department I saw this script from Bryce, but couldn't get it to work, so can't say if it would (with adjustments) fit my needs... code:
$domain = getobject("WinNT://@domain") if @error <> 0 exit(1) endif for each $thing in $domain if $thing.class = "USER" ? $thing.name endif next
Oh, I need to run this from a workstation, not on the server itself, and I'd like to go without using UserManager etc, so I can use the output for something else... Environment = NT4 ...
_________________________
Regards, Jeroen.
There are two ways to write error-free programs. Only the third one works.
|
|
Top
|
|
|
|
#62966 - 2002-02-08 04:29 PM
Re: Display account information
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Or if you want to query users other then yourself, try this (on 2k/xp):
break on $domain = getobject("WinNT://@LDOMAIN")
$domain.filter = "user",""
for each $user in $domain ? ?"Account :" $user.name ?"Fullname:" $user.fullname ?"Comment :" $user.description ? ?"Press any key for next..." gets$ next
exit 1
[EDIT]
HEHEH ! [/EDIT] -Shawn [ 08 February 2002: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#62967 - 2002-02-08 04:30 PM
Re: Display account information
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Well, for a primer on ADSI, I borrowed this from Kent.
code:
break on$DCString = "YourDomain" $User = "YourName" $DomainObj = GetObject("WinNT://" + $DCString + "/" + $user + ",user") $Name = $DomainObj.Name ? $Name ? $Description = $DomainObj.Description ? $Description ? $FullName = $DomainObj.FullName ? $FullName ? get $_
Edged out by the master... next time Shawn... next time...But where's the "any" key? [ 08 February 2002: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#62968 - 2002-02-08 08:12 PM
Re: Display account information
|
Alex.H
Seasoned Scripter
Registered: 2001-04-10
Posts: 406
Loc: France
|
Les, Didn't you see this board seems alive ? always an answer appears at last 1 minute before you post your's Seems the Force is around us !!Also, when you'll found the "any" key, could you send me the position on the keyboard ? I'm looking for it since long time (hope it's in the same place for french keyboard) [ 08 February 2002: Message edited by: Alex.H ]
_________________________
? getobject(Kixtart.org.Signature)
|
|
Top
|
|
|
|
#62972 - 2002-02-09 02:45 AM
Re: Display account information
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Yes Les,Description and Comment are different. The comment is stored on the Workstation. Here is a sample.
code:
break on gosub osver $comment9x = READVALUE("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP", "Comment") $commentNT = READVALUE("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters","srvcomment")CLS SMALL Color b+/n BOX (0,0,24,79,GRID) ; background grid Color b/n BOX (2,3,13,77,┼) ; shadow of the box Color g+/n BOX (1,2,12,76,FULL) ; Green box Color b+/n Color w+/n AT (2,5) "Userid : " ; label for user and network identification text strings AT (3,5) "Full Name : " AT (4,5) "Workstation : " AT (5,5) "NT Domain : " AT (6,5) "Logon Server : " AT (7,5) "OS : " AT (8,5) "Service Pack : " AT (9,5) "Comment : " AT (10,5)"Description : " AT (11,5)"IP Address : " Color y+/n AT (2,20) @userid ; macro's for user and network identification text strings AT (3,20) @fullname AT (4,20) @wksta AT (5,20) @domain AT (6,20) @lserver ; Lists the authenticating server AT (7,20) $os AT (8,20) $os_service_pack AT (9,20) $commentNT ; MODIFY TO USE ON WINDOWS 9X AT (10,20) @COMMENT AT (11,20) @IPADDRESS0 ? GOTO END :osver $SP6aCheck=READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009", "Installed") $SubNum="" IF $SP6aCheck=1 $SubNum=a ENDIF IF (@inwin = 1) $NT_mode="yes" ELSE $NT_mode="no" ENDIF $os="" $os_dos=@dos $os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType") $os_productSuite=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite") $os_service_pack="" $os_subversion=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber") SELECT CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") AND ($os_productSuite = "Enterprise|Terminal Server|") ; - Windows 2K Terminal Server $os="W2KTS_Terminal_Server" CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") ; - Windows XP Server $os="WXP_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") ; - Windows XP Professional $os="WXP_Professional" CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") ; - Windows 2000 Server $os="W2K_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.0") ; Windows 2000 Professional $os="W2K_Professional" CASE ($NT_mode = "yes") AND ($os_product = "LANMANNT") ; - Windows NT - $os="NT4_Domain_Controller" CASE ($NT_mode = "yes") AND ($os_product = "ServerNT") $os="NT4_Member_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") $os="NT4" CASE ($NT_mode <> "yes") AND (@dos = "4.90") $os="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 98 - $os="W98c" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"b") <> 0) $os="W98b" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"a") <> 0) $os="W98a" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") $os="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 95 - $os="W95c" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"b") <> 0) $os="W95b" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"a") <> 0) $os="W95a" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") $os="W95" CASE 1 $os="???" ; - undetermined - ENDSELECT $os_service_pack="" IF ($NT_mode = "yes") $os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","CSDVersion") IF (len($os_service_pack) <> 0) $os=$os+" SP"+substr($os_service_pack,len($os_service_pack),1)+$SubNum ENDIF ENDIF $os_type="" $os_dos=@dos SELECT CASE ($NT_mode = "yes") AND ($os_dos = "5.0") AND ($os_productSuite = "Enterprise|Terminal Server|") ; - Windows 2000 Terminal Server - $os_type="W2KTS" CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP - $os_type="WXP " CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 - $os_type="W2K " CASE ($NT_mode = "yes") ; - Windows NT - $os_type="NT4 " CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME - $os_type="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 - $os_type="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 - $os_type="W95" CASE 1 $os_type="???" ; - undetermined - ENDSELECT $os_type=LTRIM(RTRIM(substr($os_type+" ",1,5))) RETURN :END
Jeroen FYI All of this stuff can be written to a log file or screen, or Messagebox, etc... [ 09 February 2002: Message edited by: NTDOC ]
|
|
Top
|
|
|
|
#62975 - 2002-02-11 08:48 PM
Re: Display account information
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|