----- Original Message ----- 
From: "Bruce Clingaman" <[EMAIL PROTECTED]>
To: "Bclingaman (E-mail)" <[EMAIL PROTECTED]>
Sent: Wednesday, January 28, 2004 3:33 PM
Subject: FW: [ActiveDir] Logout script


> 
> 
> -----Original Message-----
> From: Bruce Clingaman [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 28, 2004 9:09 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [ActiveDir] Logout script
> 
> 
> It's a simple vbscript that enters Now into a record entered by the
> login.vbs which works but is run as a legacy script in Netlogon. The
> login.vbs retrieves an autonumber field and records it in the user's
> registry. Logout.vbs reads the reg key and finds it in the database then
> enters now in the TimeOut field.
> 
> The code is attached.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Darren Mar-Elia
> Sent: Tuesday, January 27, 2004 3:58 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [ActiveDir] Logout script
> 
> 
> Hmm. I'm assuming that when the user runs it interactively, it doesn't
> throw up any dialogs or expect response, correct? Also, are you using or
> relying on any environment variables in the script? I have seen weird
> behavior in logon scripts related to when certain environment variables
> are available and there could be similar issues at logout.
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Bruce Clingaman
> Sent: Tuesday, January 27, 2004 1:27 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [ActiveDir] Logout script
> 
> 
> I set policies to hide icons on desktop which are hidden. The logout
> script enters a field in an Access database which it does when the user
> executes it manually. XP's fast logon processing is not an issue since
> the script in question is a logout script.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Willem Kasdorp
> Sent: Tuesday, January 27, 2004 2:59 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [ActiveDir] Logout script
> 
> 
> > Login and logout scripts run under the machine context, not the user
> context.
> 
> I think you are confusing this with startup and shutdown scripts. The
> Login and Logout scripts run under the user credentials. Otherwise a lot
> of stuff would break!
> 
> > but the gp doesn't seem to work.
> 
> How did you verify this? The scripts run in the background. Also, are
> you not being bitten by XP's fast logon processing (i.e. boot once more
> and it
> works?)
> 
> --
>     Regards, Willem
> 
> 
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens Clay Perrine
> Verzonden: dinsdag 27 januari 2004 21:38
> Aan: [EMAIL PROTECTED]
> Onderwerp: RE: [ActiveDir] Logout script
> 
> Login and logout scripts run under the machine context, not the user
> context. The machine account may not have access to the network share
> that it is located on.
> 
>   Try this...  Use the AT scheduler to open a command prompt
> interactively.  The command is AT 11:00a  /interactive "cmd.exe".  This
> will pop a command window ON THE CONSOLE.  It won't open in a terminal
> server session.  When It opens, try to connect to the network location
> that the logout script is located.
> 
> 
> If you can't access the logout script, then check the share and file
> level permissions on the network share that the script is located, and
> add the everyone group read and execute permissions.
> 
> Hope that helps!
> 
> Clay Perrine, MCSE
> Microsoft Active Directory Support Team.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Bruce Clingaman
> Sent: Tuesday, January 27, 2004 2:02 PM
> To: ActiveDir (E-mail)
> Subject: [ActiveDir] Logout script
> 
> 
> I have a logout script assigned on a Test Users OU, permissions set for
> the test users group to read and apply but the script doesn't seem to
> run. The test user can browse to the script and execute it manually,
> proving the script functions correctly, but the gp doesn't seem to work.
> Other settings in the GPO are being applied.
> 
> Any ideas?
> 
> bclingaman
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> 
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> 
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> 
> List info   : http://www.activedir.org/mail_list.htm
> List FAQ    : http://www.activedir.org/list_faq.htm
> List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
> 
===============================================================
Login.vbs:
option explicit

On Error Resume Next

DIM strKeyPath, strValueName, strComputer, DC

const HKEY_CURRENT_USER = &H80000001
strComputer = "."

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim UserID, ComputerName, objNetwork
Dim objConn, objRS, AutoNum, Field
Dim fs, a
AutoNum = 0

Set objNetwork = CreateObject("WScript.Network")
Set DC = getObject("LDAP://rootDse";)
DC = DC.Get("dnsHostName")
ComputerName = objNetwork.ComputerName
UserID = objNetwork.UserName

Set objConn = CreateObject("ADODB.Connection")
objConn.Mode = 3

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data 
Source=\\manageserver\logins$\logins.mdb"

Set objRS = CreateObject("ADODB.Recordset")
objRS.Open "Logins", objConn, 2, 2

objRS.AddNew
AutoNum = objRS("ID")
objRS("ComputerName") = ComputerName
objRS("UserID") = UserID
objRS("DC") = DC
objRS("TimeIn") = Now

objRS.Update

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Dim oReg
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Logins"
strValueName = "autonum"

oReg.CreateKey HKEY_CURRENT_USER,strKeyPath,strValueName
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,AutoNum
=============================================================================
Logout.vbs:
option explicit

'On Error Resume Next

Dim UserID, ComputerName, objNetwork
Dim objConn, objRS, AutoNum
Dim a, fs, SQL
Dim strComputer, oReg, strKeyPath,strValueName

const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set objNetwork = CreateObject("WScript.Network")


Set objConn = CreateObject("ADODB.Connection")
objConn.Mode = 3
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data 
Source=\\manageserver\logins$\logins.mdb"

Set objRS = CreateObject("ADODB.Recordset")

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
        strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Logins"
strValueName = "autonum"

oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,AutoNum 

AutoNum = clng(AutoNum)

SQL = "UPDATE Logins SET TimeOut='" & Now & "' WHERE ID = " & AutoNum

'msgbox autonum

objConn.Execute(SQL)


Set objRS = Nothing
objConn.Close
Set objConn = Nothing
===============================================================================

Reply via email to