all groups > sql server dts > march 2007 >
You're in the

sql server dts

group:

ActiveX Script Task Fails


ActiveX Script Task Fails Adam S
3/20/2007 4:58:06 PM
sql server dts:
The below vbscript enumerates password age on computer accounts in Active
Directory which is then output to an xml file. Then entry point on the
ActiveX Task is Main(). This script runs fine outside of SSIS, but inside of
SSIS as an ActiveX Script Task is generates the error:
Package Validation Error
Error at ActiveX Script Task [ActiveX Script Task]: Retrieving the file name
for a component failed with error code 0x1AB6ECD4.
Error at ActiveX Script Task: There were errors during task validation.
(Microsoft.DataTransformationServices.VsIntegration)


Script:
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

Set 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)

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
End Sub
--
RE: ActiveX Script Task Fails weilu NO[at]SPAM online.microsoft.com
3/21/2007 12:00:00 AM
Hello Adam,

I found that this statement may cause the error:

Set objDate = lngDate

Could you please first check whether all the record in the recordset will
have the validate data?

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.)
RE: ActiveX Script Task Fails Adam S
3/21/2007 8:21:01 AM
Hmm...how would that statement be causing issues?

Each record may not have all fields as some could be null or blank.

I hope this helps.

Thanks for your assistance.
--
Adam S


[quoted text, click to view]
RE: ActiveX Script Task Fails Adam S
3/22/2007 3:53:08 AM
In your code you use objDate = lngdate without the "Let". I have tried both
suggested ways and the same error results.

--
Adam S


[quoted text, click to view]
RE: ActiveX Script Task Fails weilu NO[at]SPAM online.microsoft.com
3/22/2007 6:04:47 AM
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.)
RE: ActiveX Script Task Fails weilu NO[at]SPAM online.microsoft.com
3/23/2007 6:38:48 AM
Hello Adam,

Did you move the function Integer8Date out of the sub?

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: ActiveX Script Task Fails weilu NO[at]SPAM online.microsoft.com
3/27/2007 12:00:00 AM
Hi Adam,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button