Re: Multiple Login

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 03/11/05


Date: Fri, 11 Mar 2005 01:41:28 +0100

Brandon McCombs wrote:

> Instead of the current "solutions" which require database
> installations I simply added an integer attribute to the Active
> Directory schema with a minimum value of 0 and then edited the
> user object class to have the new attribute as optional.
>
> I created a logon and logoff script that will either increment or
> decrement this value to keep track of logons. The logon script
> will increment the value to 1 if it is 0 and if it is 1 it will
> increment to 2, pop up a dialog alerting the user to what is
> hapening (if they are already logged in somewhjere else) and when
> the user clicks OK the script utilizes the WMI shutdown ability to
> log the user off w/o them being able to do anything. The logoff
> script simply decrements the integer (not necessarily to a 0).

I see one problem here, and that is when the user is "thrown" off the
computer without running the logoff script that is supposed to
decrement the value.

If the computer is "brutally" powered off by the user or by a power
glitch, or for some reason the OS crashes or hangs so a reboot without
logoff must be done, the user will not be able to log on again without
contacting support personnel. If this happens in the evening or in the
weekend, and no support personnel is available, you will have a pretty
angry user on your hands I think.

> The scripts are heavily optimized by grabbing the windows
> environment variable containing the username and using that as a
> search filter in the LDAP query. That way there is only one result
> returned from the ADS query and I don't have to have a loop setup.

On Win2k/WinXP/Win2k3 computers, you don't need to do a LDAP query at
all.

For current user, you can use the ADSystemInfo object to obtain the
distinguished name of the user directly:

'--------------------8<----------------------
Set oADSystemInfo = CreateObject("ADSystemInfo")

Wscript.Echo "User's distinguished name: " & oADSystemInfo.UserName

' get AD user object
Set oADsUser = GetObject("LDAP://" & oADSystemInfo.UserName)

' get full name of the current user
sDisplayName = oADsUser.DisplayName
Wscript.Echo "User's display name: " & sDisplayName

'--------------------8<----------------------

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Re: Logoff script disappearing
    ... "Show Files" in the logoff script dialogue box, ... >what are you refering to as the "appropriate user logoff ...
    (microsoft.public.win2000.group_policy)
  • Logoff Script Running but not Applying
    ... I have a weird problem with my logoff script that disables our proxy setting ... Set objWshShell = CreateObject ...
    (microsoft.public.windows.server.general)
  • RE: CE5 clients on 2008 TS connecting to printer based on room
    ... You may need at least a logon script and a logoff script. ... this is a per-user network printer. ... Dim netPrinter, UNCpath ...
    (microsoft.public.windows.terminal_services)
  • Re: Shutdown on Logoff
    ... Did you try the scripting newsgroup ... With that in mind, we've been trying to create a logoff script (and ...
    (microsoft.public.windowsxp.general)
  • Re: Exchange Move mailbox Script
    ... the two references to the "users" OU to your the particular OU where the ... The reason is that the script is coded to reference the mailbox by the ... comments suggest that RecipName is the display name, however, the display ... which allows you to use LDAP query syntax. ...
    (microsoft.public.scripting.vbscript)