Page 1 of 1 1
Topic Options
#62964 - 2002-02-08 04:04 PM Display account information
Jeroen Offline
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
#62965 - 2002-02-08 04:23 PM Re: Display account information
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Check the manual for the following macros @USERID, @FULLNAME, @COMMENT. They give you exactly what you're looking for.
_________________________
There are two types of vessels, submarines and targets.

Top
#62966 - 2002-02-08 04:29 PM Re: Display account information
Shawn Administrator Offline
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 Offline
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 Offline
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
#62969 - 2002-02-08 08:30 PM Re: Display account information
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn and I have been "nosing" each other out for some time. I think though, you missed the subtly of my acserbic tongue. Shawn used GETS, so as long as ENTER is ANY key...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62970 - 2002-02-08 09:05 PM Re: Display account information
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Les,

Crap - I didn't catch that on the first pass - your right - should have coded "Hit the enter key to continue" ... thanks. To me - the enter key is the "any" key.

Now if I could only find the "eleven" button on my telephone so that I could call nine-eleven.

-Shawn

[ 08 February 2002: Message edited by: Shawn ]

Top
#62971 - 2002-02-08 09:42 PM Re: Display account information
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
By the by... isn't the "Description" and "Comment" something different altogether? Thought I read that somewhere...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62972 - 2002-02-09 02:45 AM Re: Display account information
NTDOC Administrator Offline
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
#62973 - 2002-02-09 03:45 AM Re: Display account information
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No DOC, it's not the Workstation comment I'm talking about. That I am aware of. When I look at an NT4 domain user account through Hyena, I have one more field available for comment.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62974 - 2002-02-09 04:03 AM Re: Display account information
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
After entering the comment "Used by Les Ligetfalvy" in Hyena for administrator, I can query the user account with:
net user administrator /domain

It returns:

code:

User name Administrator
Full Name LAN Administrator
Comment Account for administering the computer/domain
User's comment Used by Les Ligetfalvy

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62975 - 2002-02-11 08:48 PM Re: Display account information
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Les,

It looks like this field is updated via an API, not a Microsoft GUI
tool.

NetUserSetInfo: usri2_usr_comment in USER_INFO_2
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/ntlmapi_5ng4.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/ntlmapi3_0os2.asp

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.157 seconds in which 0.093 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org