Frank Doelitzscher
09-25-2002, 09:45 AM
Hello everybody!
I don´t know if this here is the right place to ask for but I hope so!
I need a script which shows me the "normal" User-informations
AND the lokal Mashine name = the name of the PC on which the user is currently logged on.
(like e.g NTFinger, but this do´t show me the mashine)
Does anybody know such a script, or could mail me a solution??
Thanks in forward!
Best Regards
Frank Dölitzscher
Paulo
10-22-2002, 06:43 AM
'Syntax: xFinger.vbs [domainuser_name]
'************************************************* **************
Option Explicit
Dim inputStr, UserName, Domain, splitInput, sName, oArgs, Session
Dim oUser, userFullName, userHome, fService, LoggedOn, q
On Error Resume Next
q = Chr(34)
Set oArgs = Wscript.Arguments
'Check for Script Argument. If not supplied, then
'display proper syntax calling "NoArgs" help sub.
If oArgs.Count <> 1 Then NoArgs
inputStr = oArgs(0)
'Split argument string with "" and assign result to
'the Domain and User names.
If InStr(inputStr, "") <> 0 then
splitInput = Split(inputStr, "")
Else: NoArgs
End If
Domain = Trim(splitInput(0))
UserName = Trim(splitInput(1))
'If domain or user name is empty call a help sub.
If Domain = "" Or UserName = "" Then NoArgs
'Connect to SAM database. Error will be raised if
'domain or user name is invalid.
Set oUser = GetObject("WinNT://" & Domain & "/" & UserName & ",user")
If Err.Number <> 0 Then MsgBox "Cannot locate Domain " & _
q & Domain & q & " or user account " & _
q & UserName & q & " does not exists.", _
64, "Error:": Wscript.Quit
'Get user's Full Name and Home Drive account property.
'User home drive property is used to retrieve "Home" server name. 'If this property is not defined then display error and exit.
userFullName = oUser.FullName
userHome = oUser.HomeDirectory
If userHome = "" then MsgBox "Home Server for user " & _
q & UserName & q & " not specified." , _
64, "Error:": Wscript.Quit
'Retrieve server name.
sName = Split(userHome, "")
'Connect to home server and create a session object.
Set fService = GetObject("WinNT://" & sName(2) & "/LanmanServer")
If Err.Number <> 0 Then MsgBox "Can not connect to user Home" & _
" Server. Server is down, " & _
"or you do not have enough privileges!", _
64, "Error:": Wscript.Quit
'Enumerate current sessions on the server matching session users 'to the given user name. If match is found retrieve computer name 'the user is connected from and build a "LoggedOn" list string.
For Each Session In fService.Sessions
If LCase(Session.User) = LCase(UserName) Then
LoggedOn = LoggedOn & vbcr & Session.Computer
End If
Next
'If string is not empty then display it in the message box.
If LoggedOn = "" then
MsgBox "User " & q & UserName & q & " (" & _
userFullName & ") is not logged on.", 64, "Query:"
Else: MsgBox "User " & q & UserName & q & " (" & _
userFullName & ") logged on to the following workstations: " & _
vbcr & vbcr & LoggedOn, , "Query"
End If
Sub NoArgs()
MsgBox "SYNTAX: xFinger.vbs [DomainUser_Name]" & vbcr & vbcr & _
"Domain - Focus domain." & vbcr & _
"User_Name - User name to query for." & vbcr & vbcr & _
"NOTE: For the script to work, user must" & _
" have a home drive specified" & vbcr &_
" in the domain account properties." & vbcr, 64, "Syntax:"
Wscript.Quit
End Sub
------------
Frank Doelitzscher at 9/25/2002 10:45:37 AM
Hello everybody!
I don´t know if this here is the right place to ask for but I hope so!
I need a script which shows me the "normal" User-informations
AND the lokal Mashine name = the name of the PC on which the user is currently logged on.
(like e.g NTFinger, but this do´t show me the mashine)
Does anybody know such a script, or could mail me a solution??
Thanks in forward!
Best Regards
Frank Dölitzscher