In your code you use objDate = lngdate without the "Let". I have tried both
"Wei Lu [MSFT]" wrote:
> Hello Adam,
>
> Based on my discussion of internal team, you should use the following
> statement instead of the original.
>
> Let objDate = lngDate
>
> Based on my test, this could run without any error in the SSIS.
>
> The following is tha full code:
>
> Option Explicit
> 'On Error Resume Next
> Sub Main()
> Dim objConnection, objCommand, objRecordSet, objRootDSE, objShell
> Dim objDate, myFile, objFSO
> Dim strKMA, strDivision, strDNSDomain, strOU, strFilePath, strName,
> strSamName, strCategory
> Dim intType, intChoice, x, lngBias, lngBiasKey, lngDate, intAcctCont,
> dtmPwdLastSet
>
>
> Const ADS_SCOPE_SUBTREE = 2
>
> ' userAccountControl attribute values
> Const SCRIPT = 1
> Const ACCOUNTDISABLE = 2
> Const HOMEDIR_REQUIRED = 8
> Const LOCKOUT = 16
> Const PASSWD_NOTREQD = 32
> Const PASSWD_CANT_CHANGE = 64
> Const ENCRYPTED_TEXT_PWD_ALLOWED = 128
> Const TEMP_DUPLICATE_ACCOUNT = 256
> Const NORMAL_ACCOUNT = 512
> Const INTERDOMAIN_TRUST_ACCOUNT = 2048
> Const WORKSTATION_TRUST_ACCOUNT = 4096
> Const SERVER_TRUST_ACCOUNT = 8192
> Const DONT_EXPIRE_PASSWORD = 65536
> Const MNS_LOGON_ACCOUNT = 131072
> Const SMARTCARD_REQUIRED = 262144
> Const TRUSTED_FOR_DELEGATION = 524288
> Const NOT_DELEGATED = 1048576
> Const USE_DES_KEY_ONLY = 2097152
> Const DONT_REQ_PREAUTH = 4194304
> Const PASSWORD_EXPIRED = 8388608
> Const TRUSTED_TO_AUTH_FOR_DELEGATION = 16777216
>
>
>
>
> ' Obtain local time zone bias from machine registry.
> Set objShell = CreateObject("Wscript.Shell")
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set myFile = objFSO.CreateTextFile("C:\SMS_Reports\ComputerAge.xml", true)
> myFile.WriteLine Chr(60) & Chr(63) & "xml version" & Chr(61) & Chr(34) &
> "1.0" & Chr(34) & " encoding" & Chr(61) & Chr(34) & "utf-8" & Chr(34) &
> Chr(63) & Chr(62)
> myFile.WriteLine Chr(60) & "ComputerAge" & Chr(62)
> lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
> & "TimeZoneInformation\ActiveTimeBias")
> If UCase(TypeName(lngBiasKey)) = "LONG" Then
> lngBias = lngBiasKey
> ElseIf UCase(TypeName(lngBiasKey)) = "VARIANT()" Then
> lngBias = 0
> For k = 0 To UBound(lngBiasKey)
> lngBias = lngBias + (lngBiasKey(k) * 256^k)
> Next
> End If
>
>
> ' Determine the DNS domain from the RootDSE object.
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strDNSDomain = objRootDSE.Get("DefaultNamingContext")
>
> Set objConnection = CreateObject("ADODB.Connection")
> Set objCommand = CreateObject("ADODB.Command")
> objConnection.Provider = "ADsDSOObject"
> objConnection.Open "Active Directory Provider"
> Set objCommand.ActiveConnection = objConnection
>
> objCommand.Properties("Page Size") = 100
> objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> 'objCommand.Properties("Timeout") = 90
> objCommand.Properties("Cache Results") = False
> objCommand.Properties("Sort On") = "userAccountControl"
>
> strCategory = "computer"
>
>
>
> objCommand.CommandText = "SELECT Name, samAccountName, pwdLastSet,
> userAccountControl From " _
> & "'LDAP://" & strDNSDomain & "' WHERE objectCategory='" & strCategory &
> "'"
>
>
>
> Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
> Do Until objRecordSet.EOF
> strName = objRecordSet.Fields("Name")
> lngDate = objRecordSet.Fields("pwdLastSet")
> strSamName = objRecordSet.Fields("sAMAccountName")
> intAcctCont= objRecordSet.Fields("userAccountControl")
> If intAcctCont And ACCOUNTDISABLE Then
> intAcctCont = "Disabled"
> Elseif intAcctCont And NORMAL_ACCOUNT Then
> intAcctCont = "Active"
> End If
>
> objDate = lngDate
> dtmPwdLastSet = Integer8Date(objDate, lngBias)
> dtmPwdLastSet = DateDiff("d",dtmPwdLastSet,Date)
>
> myFile.WriteLine vbTab & Chr(60) & "Computer" & Chr(62)
> myFile.WriteLine vbTab & vbTab & Chr(60) & "ComputerName" & Chr(62) &
> strSamName & Chr(60) & Chr(47) & "ComputerName" & Chr(62)
> myFile.WriteLine vbTab & vbTab & Chr(60) & "PwdLastSet" & Chr(62) &
> dtmPwdLastSet & Chr(60) & Chr(47) & "PwdLastSet" & Chr(62)
> myFile.WriteLine vbTab & vbTab & Chr(60) & "sAMAccountName" & Chr(62) &
> strSamName & Chr(60) & Chr(47) & "sAMAccountName" & Chr(62)
> myFile.WriteLine vbTab & vbTab & Chr(60) & "Status" & Chr(62) &
> intAcctCont & Chr(60) & Chr(47) & "Status" & Chr(62)
> myFile.WriteLine vbTab & Chr(60) & Chr(47) & "Computer" & Chr(62)
>
> objRecordSet.MoveNext
> Loop
>
>
> myFile.WriteLine Chr(60) & Chr(47) & "ComputerAge" & Chr(62)
>
>
> End Sub
>
> Function Integer8Date(objDate, lngBias)
> ' Function to convert Integer8 (64-bit) value to a date, adjusted for
> ' time zone bias.
> Dim lngAdjust, lngDate, lngHigh, lngLow
> lngAdjust = lngBias
> lngHigh = objDate.HighPart
> lngLow = objDate.LowPart
> ' Account for bug in IADsLargeInteger property methods.
> If (lngHigh = 0) And (lngLow = 0) Then
> lngAdjust = 0
> End If
> lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) + lngLow) / 600000000 -
> lngAdjust) / 1440
> Integer8Date = CDate(lngDate)
> End Function
>
>
> Hope this will be helpful!
>
> Sincerely,
>
> Wei Lu
>
> Microsoft Online Community Support
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. >
> ==================================================
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>