Active Directory에서 모든 사용자를 가져 오려고 시도했지만 모든 레코드를 가져올 수 있지만 표의 데이터를 읽을 때 SYSTEM.BYTE[]
(로그온 시간)으로 표시됩니다. , 그것을 SQL 테이블에 삽입하기 전에 변환해야합니다.Active Directory에서 SQL Server로 로그온 시간 가져 오기
나는 인터넷 검색을 수행하여 먼저 바이트로 변환 한 다음 문자열로 삽입하고 삽입하는 등 데이터를 읽을 수있는 솔루션을 발견했지만 구현할 수는 없습니다.
아무도 도와 줄 수 있습니까?
SQL Server 2005에 삽입하고 SSIS를 사용하여 모든 데이터를 가져 오는 중입니다. 쿼리 할 때 ADSI에 대한 제한 사항이 있으므로 사용자 지정 스크립트를 사용하고 1000 개가 넘는 페이지를 기본값으로 설정하면 1000 개의 레코드 만 가져옵니다.) 를 Active Directory에서 모든 레코드를 가져 오지하기 위해 아래 내가 ADSI에서 내 기록을 당겨 얼마나 내 사용자 지정 스크립트입니다
' Microsoft SQL Server Integration Services user script component
' This is your new script component in Microsoft Visual Basic .NET
' ScriptMain is the entrypoint class for script components
Option Strict Off
Imports System
Imports System.Data
Imports System.DirectoryServices
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub CreateNewOutputRows()
Dim arrayDomains As String()
ReDim arrayDomains(1)
arrayDomains(0) = "LDAP://DC=cba,DC=acb,DC=com"
arrayDomains(1) = "LDAP://DC=abc,DC=bca,DC=com"
Dim Domain As String
For Each Domain In arrayDomains
Dim objSearch As New DirectorySearcher()
objSearch.SearchRoot = New DirectoryEntry(Domain)
objSearch.Filter = "(&(objectclass=user)(objectcategory=Person)(samAccountType=805306368))"
'(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.804:=14))(samAccountType=805306368))
objSearch.SearchScope = SearchScope.Subtree
objSearch.PageSize = 999
objSearch.ServerTimeLimit = New TimeSpan(0, 15, 0)
objSearch.ClientTimeout = New TimeSpan(0, 30, 0)
objSearch.PropertiesToLoad.Add("cn")
objSearch.PropertiesToLoad.Add("c")
objSearch.PropertiesToLoad.Add("department")
objSearch.PropertiesToLoad.Add("displayName")
objSearch.PropertiesToLoad.Add("distinguishedName")
objSearch.PropertiesToLoad.Add("employeeID")
objSearch.PropertiesToLoad.Add("extensionAttribute14")
objSearch.PropertiesToLoad.Add("extensionAttribute2")
objSearch.PropertiesToLoad.Add("givenName")
objSearch.PropertiesToLoad.Add("l")
objSearch.PropertiesToLoad.Add("lastLogon")
objSearch.PropertiesToLoad.Add("logonHours")
objSearch.PropertiesToLoad.Add("mail")
objSearch.PropertiesToLoad.Add("manager")
objSearch.PropertiesToLoad.Add("physicalDeliveryOfficeName")
objSearch.PropertiesToLoad.Add("postalCode")
objSearch.PropertiesToLoad.Add("pwdLastSet")
objSearch.PropertiesToLoad.Add("sn")
objSearch.PropertiesToLoad.Add("st")
objSearch.PropertiesToLoad.Add("streetAddress")
objSearch.PropertiesToLoad.Add("telephoneNumber")
objSearch.PropertiesToLoad.Add("title")
objSearch.PropertiesToLoad.Add("userAccountControl")
objSearch.PropertiesToLoad.Add("whenCreated")
Dim colQueryResults As SearchResultCollection
colQueryResults = objSearch.FindAll()
Dim objResult As SearchResult
For Each objResult In colQueryResults
'Console.WriteLine("3")
'
' Add rows by calling AddRow method on member variable called "<Output Name>Buffer"
' E.g., MyOutputBuffer.AddRow() if your output was named "My Output"
'
Output0Buffer.AddRow()
If objResult.Properties.Contains("cn") AndAlso objResult.Properties("cn")(0) IsNot Nothing Then
Output0Buffer.cn = objResult.Properties("cn")(0).ToString()
End If
If objResult.Properties.Contains("c") AndAlso objResult.Properties("c")(0) IsNot Nothing Then
Output0Buffer.c = objResult.Properties("c")(0).ToString()
End If
If objResult.Properties.Contains("department") AndAlso objResult.Properties("department")(0) IsNot Nothing Then
Output0Buffer.Department = objResult.Properties("department")(0).ToString()
End If
If objResult.Properties.Contains("displayName") AndAlso objResult.Properties("displayname")(0) IsNot Nothing Then
Output0Buffer.DisplayName = objResult.Properties("displayName")(0).ToString()
End If
If objResult.Properties.Contains("distinguishedName") AndAlso objResult.Properties("distinguishedName")(0) IsNot Nothing Then
Output0Buffer.DistinguishedName = objResult.Properties("distinguishedName")(0).ToString()
End If
If objResult.Properties.Contains("employeeID") AndAlso objResult.Properties("employeeID")(0) IsNot Nothing Then
Output0Buffer.EmployeeID = objResult.Properties("employeeID")(0).ToString()
End If
If objResult.Properties.Contains("extensionAttribute14") AndAlso objResult.Properties("extensionAttribute14")(0) IsNot Nothing Then
Output0Buffer.ExtensionAttribute14 = objResult.Properties("extensionAttribute14")(0).ToString()
End If
If objResult.Properties.Contains("extensionAttribute2") AndAlso objResult.Properties("extensionAttribute2")(0) IsNot Nothing Then
Output0Buffer.ExtensionAttribute2 = objResult.Properties("extensionAttribute2")(0).ToString()
End If
If objResult.Properties.Contains("givenName") AndAlso objResult.Properties("givenName")(0) IsNot Nothing Then
Output0Buffer.GivenName = objResult.Properties("givenName")(0).ToString()
End If
If objResult.Properties.Contains("l") AndAlso objResult.Properties("l")(0) IsNot Nothing Then
Output0Buffer.L = objResult.Properties("l")(0).ToString()
End If
If objResult.Properties.Contains("lastLogon") AndAlso objResult.Properties("lastLogon")(0) <> 0 AndAlso objResult.Properties("lastLogon")(0) IsNot Nothing Then
Output0Buffer.LastLogon = DateTime.Parse(DateTime.FromFileTime(objResult.Properties("lastLogon")(0).ToString()))
End If
'If objResult.Properties.Contains("pwdLastSet") AndAlso objResult.Properties("pwdLastSet")(0) <> 0 AndAlso objResult.Properties("pwdLastSet")(0) IsNot Nothing Then
' Output0Buffer.PwdLastSet = DateTime.Parse(DateTime.FromFileTime(objResult.Properties("pwdLastSet")(0)).ToString())
'End If
If objResult.Properties.Contains("logonHours") AndAlso objResult.Properties("logonHours")(0) IsNot Nothing Then
Output0Buffer.LogonHours = objResult.Properties("logonHours")(0).ToString()
End If
If objResult.Properties.Contains("mail") AndAlso objResult.Properties("mail")(0) IsNot Nothing Then
Output0Buffer.Mail = objResult.Properties("mail")(0).ToString()
End If
If objResult.Properties.Contains("manager") AndAlso objResult.Properties("manager")(0) IsNot Nothing Then
Output0Buffer.Manager = objResult.Properties("manager")(0).ToString()
End If
If objResult.Properties.Contains("physicalDeliveryOfficeName") AndAlso objResult.Properties("physicalDeliveryOfficeName")(0) IsNot Nothing Then
Output0Buffer.PhysicalDeliveryOfficeName = objResult.Properties("physicalDeliveryOfficeName")(0).ToString()
End If
If objResult.Properties.Contains("postalCode") AndAlso objResult.Properties("postalCode")(0) IsNot Nothing Then
Output0Buffer.PostalCode = objResult.Properties("postalCode")(0).ToString()
End If
If objResult.Properties.Contains("pwdLastSet") AndAlso objResult.Properties("pwdLastSet")(0) <> 0 AndAlso objResult.Properties("pwdLastSet")(0) IsNot Nothing Then
Output0Buffer.PwdLastSet = DateTime.Parse(DateTime.FromFileTime(objResult.Properties("pwdLastSet")(0)).ToString())
End If
'If objResult.Properties.Contains("pwdLastSet") AndAlso objResult.Properties("pwdLastSet")(0) IsNot Nothing Then
' Output0Buffer.PwdLastSet = objResult.Properties("pwdLastSet")(0).ToString()
'End If
If objResult.Properties.Contains("sn") AndAlso objResult.Properties("sn")(0) IsNot Nothing Then
Output0Buffer.Sn = objResult.Properties("sn")(0).ToString()
End If
If objResult.Properties.Contains("st") AndAlso objResult.Properties("st")(0) IsNot Nothing Then
Output0Buffer.St = objResult.Properties("st")(0).ToString()
End If
If objResult.Properties.Contains("streetAddress") AndAlso objResult.Properties("streetAddress")(0) IsNot Nothing Then
Output0Buffer.StreetAddress = objResult.Properties("streetAddress")(0).ToString()
End If
If objResult.Properties.Contains("telephoneNumber") AndAlso objResult.Properties("telephoneNumber")(0) IsNot Nothing Then
Output0Buffer.TelephoneNumber = objResult.Properties("telephoneNumber")(0).ToString()
End If
If objResult.Properties.Contains("title") AndAlso objResult.Properties("title")(0) IsNot Nothing Then
Output0Buffer.Title = objResult.Properties("title")(0).ToString()
End If
If objResult.Properties.Contains("userAccountControl") AndAlso objResult.Properties("userAccountControl")(0) IsNot Nothing Then
Output0Buffer.UserAccountControl = objResult.Properties("userAccountControl")(0).ToString()
End If
If objResult.Properties.Contains("whenCreated") AndAlso objResult.Properties("whenCreated")(0) IsNot Nothing Then
Output0Buffer.WhenCreated = CDate(objResult.Properties("whenCreated")(0).ToString())
End If
Next
Next
End Sub
End Class