SQLScholar
Programmer
Hey all,
I have the below code:
I have used this code in vbs and it works perfectly. Then added it in sql SSIS script task. It has changed bits (i.e. removed SET) and now it doesnt work.
It doesnt like this line:
objLastLogon = objLastLogon + #1/1/1601#
adding a double to a date. How can i sort this out??
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have the below code:
Code:
Option Explicit Off
Option Strict Off
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
'
' Add your code here
'
StrConnect = "Driver={SQL Server};Server=(local);Database=audit;UID=sa;PWD=password"
cnt = CreateObject("ADODB.Connection")
cnt.Open(StrConnect)
recordSet = CreateObject("ADODB.Recordset")
SQLStr = "Select * from aduseroutput where lastlogontimestamp <> 0 and objectclass = 'user'"
recordSet.Open(SQLStr, cnt, 1, 1)
recordset.MoveFirst()
x = 0
Do Until recordset.EOF
objUser = GetObject("LDAP://" & recordset.fields(0).Value)
objLastLogon = objUser.Get("lastLogonTimestamp")
objLastLogon = objLastLogon.HighPart * (2 ^ 32) + objLastLogon.LowPart
objLastLogon = objLastLogon / (60 * 10000000)
objLastLogon = objLastLogon / 1440
objLastLogon = objLastLogon + #1/1/1601#
cnt.Execute("Update aduseroutput set Convlastlogontimestamp = '" & CStr(objLastLogon) & "' where DN = '" & Recordset.fields(0).Value & "'")
objUser = Nothing
objLastLogon = Nothing
Recordset.MoveNext()
Loop
recordset.Close()
cnt.Close()
recordset = Nothing
cnt = Nothing
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
I have used this code in vbs and it works perfectly. Then added it in sql SSIS script task. It has changed bits (i.e. removed SET) and now it doesnt work.
It doesnt like this line:
objLastLogon = objLastLogon + #1/1/1601#
adding a double to a date. How can i sort this out??
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------