Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Logged On User on Computer Assistance

HTVi
TV Discussion Newsgroups

Logged On User on Computer Assistance
TeddyBear 6/29/2007 1:32:04 PM
I would like to retrieve the UserID/Username of the user logged on either on
a network or the local PC. Then I would like to change the case of the
Username to lower case. I would then like to identify who the user is in my
script and based on who it is take the appropriate action.
Re: Logged On User on Computer Assistance
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 6/29/2007 6:26:26 PM

"TeddyBear" <TeddyBear[ at ]discussions.microsoft.com> wrote in message
news:29F770C0-20BA-4322-8981-3F27C4FCAAB4[ at ]microsoft.com...
[Quoted Text]
>I would like to retrieve the UserID/Username of the user logged on either
>on
> a network or the local PC. Then I would like to change the case of the
> Username to lower case. I would then like to identify who the user is in
> my
> script and based on who it is take the appropriate action.

We need to know who is running the script and from where.

Is the user running the script, perhaps in a logon script?
Are you running the script from another machine?

In a logon script (or a script run by the user), the following VBScript
program would retrieve the user Distinguished Name and use this to retrieve
the NT Name of the user (the "pre-Windows 2000 logon name"):
==============
Set objSysInfo = CreateObject("ADSystemInfo")
' Retrieve current user Distinguished Name.
strUserDN = objSysInfo.UserName
' Bind to user object.
Set objUser = GetObject("LDAP://" & strUserDN)
' Retrieve NT Name (pre-Windows 2000 logon name).
strNTName = objUser.sAMAccountName
' Perform action based on NT Name (lower case).
Select Case LCase(strNTName)
Case "jimsmith"
' do something.
Case "sallyrogers"
' do something.
Case "willjohnson"
' do something.
End Select
==========
If all you need is the NT Name of the user, it can also be retrieved from
the wshNetwork object:
===========
Set objNetwork = CreateObject("Wscript.Network")
strNTName = objNetwork.UserName
' ...
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen