1. Создаем Data Flow Task, Script Component как data source
2. Добавляем нужные колонки в исходящий поток данных (как на картинке)
3. Пишем аналогичный скрипт:
' Microsoft SQL Server Integration Services Script Component
' Write scripts using Microsoft Visual Basic 2008.
' ScriptMain is the entry point class of the script.
Imports System
Imports System.Data
Imports System.Math
Imports System.DirectoryServices
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
_
_
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub PreExecute()
MyBase.PreExecute()
'
' Add your code here for preprocessing or remove if not needed
'
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
'
' Add your code here for postprocessing or remove if not needed
' You can set read/write variables here, for example:
' Me.Variables.MyIntVar = 100
'
End Sub
Public Overrides Sub CreateNewOutputRows()
Dim sServerName As String = "mail"
Dim ldapServerName As String = "LEI-DC-01"
Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://" & ldapServerName & _
"/OU=HRX,OU=CENTRAL OFFICE,OU=CEO_USERS,DC=syd-cenet,DC=ceo,DC=syd,DC=catholic,DC=edu,DC=au")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
Dim oResults As SearchResultCollection
Dim oResult As SearchResult
oSearcher.PropertiesToLoad.Add("EmployeeID")
oSearcher.PropertiesToLoad.Add("samAccountName")
oSearcher.PropertiesToLoad.Add("mail")
oResults = oSearcher.FindAll
For Each oResult In oResults
With Output0Buffer
.AddRow()
.EmployeeID = oResult.GetDirectoryEntry().Properties("EmployeeID").Value
.Email = oResult.GetDirectoryEntry().Properties("mail").Value
.samAccountName = oResult.GetDirectoryEntry().Properties("samAccountName").Value
End With
Next
End Sub
End Class
2. Добавляем нужные колонки в исходящий поток данных (как на картинке)
3. Пишем аналогичный скрипт:
' Microsoft SQL Server Integration Services Script Component
' Write scripts using Microsoft Visual Basic 2008.
' ScriptMain is the entry point class of the script.
Imports System
Imports System.Data
Imports System.Math
Imports System.DirectoryServices
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub PreExecute()
MyBase.PreExecute()
'
' Add your code here for preprocessing or remove if not needed
'
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
'
' Add your code here for postprocessing or remove if not needed
' You can set read/write variables here, for example:
' Me.Variables.MyIntVar = 100
'
End Sub
Public Overrides Sub CreateNewOutputRows()
Dim sServerName As String = "mail"
Dim ldapServerName As String = "LEI-DC-01"
Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://" & ldapServerName & _
"/OU=HRX,OU=CENTRAL OFFICE,OU=CEO_USERS,DC=syd-cenet,DC=ceo,DC=syd,DC=catholic,DC=edu,DC=au")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
Dim oResults As SearchResultCollection
Dim oResult As SearchResult
oSearcher.PropertiesToLoad.Add("EmployeeID")
oSearcher.PropertiesToLoad.Add("samAccountName")
oSearcher.PropertiesToLoad.Add("mail")
oResults = oSearcher.FindAll
For Each oResult In oResults
With Output0Buffer
.AddRow()
.EmployeeID = oResult.GetDirectoryEntry().Properties("EmployeeID").Value
.Email = oResult.GetDirectoryEntry().Properties("mail").Value
.samAccountName = oResult.GetDirectoryEntry().Properties("samAccountName").Value
End With
Next
End Sub
End Class
Комментариев нет:
Отправить комментарий