Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Log off Script

Reply
 
Old 05-13-2009   #1 (permalink)
Bre-x


 
 

Log off Script

I am going to setup a log off script. It will connect to a database and
update a record ...

'Create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'Open the connection to the database
Connection.Open "DSN=INTRANET"

My question is where the DSN has to be? On the Client? or On the Server?
Our workstations as part of a windows 2003 domain controller.

Thank you all

Bre-x



My System SpecsSystem Spec
Old 05-13-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Log off Script


"Bre-x" <cholotron@xxxxxx> wrote in message
news:%239vK5J$0JHA.2516@xxxxxx
Quote:

>I am going to setup a log off script. It will connect to a database and
>update a record ...
>
> 'Create an instance of the ADO connection and recordset objects
> Set Connection = Server.CreateObject("ADODB.Connection")
> Set Recordset = Server.CreateObject("ADODB.Recordset")
>
> 'Open the connection to the database
> Connection.Open "DSN=INTRANET"
>
> My question is where the DSN has to be? On the Client? or On the Server?
> Our workstations as part of a windows 2003 domain controller.
>
> Thank you all
>
> Bre-x
Logoff scripts run on the client with the credentials of the user. The DSN
would need to be on the client, just as if the user ran the script
themselves.

When I run scripts that use ADO I don't use DSN's. My connection string
specifies the server, driver, etc. You can search on the web for example
connection strings. For SQL server (using Windows integrated authentication)
I use a string similar to:

strConnect = "DRIVER=SQL Server;" _
& "Trusted_Connection=Yes;" _
& "DATABASE=MyDatabaseName;" _
& "SERVER=MyServer\MyInstance"
adoConnection.ConnectionString = strConnect

For Microsoft Access I use a string similar to:

strConnect "DRIVER=Microsoft Access Driver (*.mdb);" _
& "FIL=MS Access;DriverId=25;" _
& "DBQ=c:\databases\MyDB.mdb;"

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 05-13-2009   #3 (permalink)
Bre-x


 
 

Re: Log off Script

Thank you for your help.

Now my script is giving me a Type Mismatch error




' Dim Variables
'-----------------------
Dim conn
Dim sql
Dim objNetwork
Dim CC

' Set Database Connection
'------------------------
Set conn = CreateObject("ADODB.Connection")
conn.open "DSN=INTRANET"
Set rs = CreateObject("ADODB.Recordset")

' Get User Name
'------------------------
Set objNetwork = CreateObject("WScript.Network")

' Count Records
'------------------------
sql = "SELECT count(*) as CC FROM sys_user WHERE user_name='" &
objNetwork.UserName & "'"
rs.Open sql, conn, 3, 3
CC = rs.Fields(0).Value

if CC = 1 Then
'Update Table Query
'------------------------
sql = "UPDATE sys_user SET last_logoff = '" & Now & "' WHERE user_name='"
& objNetwork.UserName & "'"
conn.Execute sql
else
'Insert Record
'------------------------
sql = "INSERT INTO sys_user (user_name, user_ip, user_pc, last_login,
last_logoff) 'VALUES ('" & objNetwork.UserName & "', '0.0.0.0',
'none','none','" & Now & "')"
conn.Execute sql
end if

' Close Connections
'------------------------
conn.close
Set rs = Nothing
Set conn = Nothing




My System SpecsSystem Spec
Old 05-13-2009   #4 (permalink)
Bre-x


 
 

Re: Log off Script

CC = cint(rs.Fields(0).Value)

Sorry. I am very new at this.

thank you all


My System SpecsSystem Spec
Old 05-14-2009   #5 (permalink)
ju.c


 
 

Re: Log off Script

Please include the older postings, too. Thanks.


"Bre-x" <cholotron@xxxxxx> wrote in message news:uHleouA1JHA.5440@xxxxxx
Quote:

> CC = cint(rs.Fields(0).Value)
>
> Sorry. I am very new at this.
>
> thank you all
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logon Script Causing Laptops To Hang - Problems in script? VB Script
problem passing args to script 'There is no script engine for file extenstion' VB Script
Include another script, keep variables in included script? PowerShell
Script file has 'OS Handle' error when run from script PowerShell
Can you drag-n-drop a file on top of a PS script to run the script? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46