0

我正在使用一个脚本,它应该从我们的 LDAP 中提取 1400 条记录(我通过在 Apache Directory Studio 中运行相同的过滤器进行了双重检查,并且查询成功运行)。输出将用作 SSIS SQL 源。我知道我们在 LDAP 上的页面限制设置为 2000,但是每次我们运行下面的脚本时,我们都会收到以下错误消息“超出大小限制”。谁能看到可以在我们的脚本中修改什么来克服这个错误消息?我已经尝试设置“request.SizeLimit = Integer.MaxValue”并在之后尝试了“request.SizeLimit = 2000”,但是仍然存在“超出大小限制”的相同错误消息。任何帮助将不胜感激。

Imports System
Imports System.Data
Imports System.Math
Imports System.DirectoryServices.Protocols
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute()> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent

Public Overrides Sub CreateNewOutputRows()

    'Set ldap server string and port number that will be bound against
    Dim con As New LdapConnection(New LdapDirectoryIdentifier("ldap.company.com:636"))

    'Set the username and password of the service account used to bind against ldap.company.com
    Dim credential As New System.Net.NetworkCredential("USERNAME", "PASSWORD")

    'Enable SSL ring bind to ldap.company.com
    con.SessionOptions.SecureSocketLayer = True

    'Set authentication method used ring bind to ldap.company.com
    con.AuthType = AuthType.Basic

    'Pass along the credentials established earlier
    con.Credential = credential

    Using con

        'Set what attributes to pull from ldap.company.com
        Dim attributesToReturn As String() = New String() {"uid", "companyID", "givenName", "Nickname", "MiddleName1", "sn", "generationQualifier", "Degree", "displayName", "mail", "PSCareerC1", "PSCareerDescC1", "PSProgC1", "PSExpTermC1", "Affiliation", "PrimaryAffiliation", "PrincipalName", "telephoneNumber", "OrgUnit", "title"}

        'Set the search scope and filter for the query against ldap.company.com
        Dim request As New SearchRequest("OU=people,DC=company,DC=com", "(objectClass=person)", SearchScope.Subtree, attributesToReturn)

        Dim response As SearchResponse = DirectCast(con.SendRequest(request, New TimeSpan(1, 0, 0, 0, 0)), SearchResponse)

        'Send ldap bind request to ldap.company.com using the paramaters set above
        con.Bind()

        If response.Entries.Count > 0 Then

            Dim counter As Integer = 0

            'Enumerate through each entry, pulling each of the attributes requested
            For Each entry As SearchResultEntry In response.Entries

                OutputBuffer.AddRow()

                Dim Affiliations(5) As String
                Dim Title(5) As String

                OutputBuffer.DN = entry.DistinguishedName.ToString()

                Dim attributes As SearchResultAttributeCollection = entry.Attributes
                For Each attribute As DirectoryAttribute In attributes.Values

                    For i As Integer = 0 To attribute.Count - 1
                        If TypeOf attribute(i) Is String Then

                            If attribute.Name = "uid" Then

                                'Set NetID to the uid attribute value from ldap.company.com
                                OutputBuffer.NetID = attribute(i).ToString()

                            ElseIf attribute.Name = "givenName" Then

                                'Set FirstName to the givenName attribute value from ldap.company.com
                                OutputBuffer.FirstName = attribute(i).ToString()

                            ElseIf attribute.Name = "Nickname" Then

                                'Set Nickname to the Nickname attribute value from ldap.company.com
                                OutputBuffer.Nickname = attribute(i).ToString()

                            ElseIf attribute.Name = "MiddleName1" Then

                                'Set MiddleName to the MiddleName1 attribute value from ldap.company.com
                                OutputBuffer.MiddleName = attribute(i).ToString()

                            ElseIf attribute.Name = "sn" Then

                                'Set LastName to the sn attribute value from ldap.company.com
                                OutputBuffer.LastName = attribute(i).ToString()

                            ElseIf attribute.Name = "generationQualifier" Then

                                'Set Suffix to the generationQualifier attribute value from ldap.company.com
                                OutputBuffer.Suffix = attribute(i).ToString()

                            ElseIf attribute.Name = "Degree" Then

                                'Set Degree to the Degree attribute value from ldap.company.com
                                OutputBuffer.Degree = attribute(i).ToString()

                            ElseIf attribute.Name = "displayName" Then

                                'Set DisplayName to the displayName attribute value from ldap.company.com
                                OutputBuffer.DisplayName = attribute(i).ToString()

                            ElseIf attribute.Name = "companyID" Then

                                'Set UniqueID to the companyID attribute value from ldap.company.com
                                OutputBuffer.UniqueID = attribute(i).ToString()

                            ElseIf attribute.Name = "mail" Then

                                'Set Email to the mail attribute value from ldap.company.com
                                OutputBuffer.Email = attribute(i).ToString()

                            ElseIf attribute.Name = "title" Then

                                OutputBuffer.Title = attribute(i).ToString()

                                If String.IsNullOrEmpty(Title(0)) Then
                                    Title(0) = attribute(i).ToString()
                                    OutputBuffer.Title = Title(0)
                                ElseIf String.IsNullOrEmpty(Title(1)) Then
                                    Title(1) = attribute(i).ToString()
                                    OutputBuffer.Title = Title(0) + ", " + Title(1)
                                ElseIf String.IsNullOrEmpty(Title(2)) Then
                                    Title(2) = attribute(i).ToString()
                                    OutputBuffer.Title = Title(0) + ", " + Title(1) + ", " + Title(2)
                                ElseIf String.IsNullOrEmpty(Title(3)) Then
                                    Title(3) = attribute(i).ToString()
                                    OutputBuffer.Title = Title(0) + ", " + Title(1) + ", " + Title(2) + ", " + Title(3)
                                ElseIf String.IsNullOrEmpty(Title(4)) Then
                                    Title(4) = attribute(i).ToString()
                                    OutputBuffer.Title = Title(0) + ", " + Title(1) + ", " + Title(2) + ", " + Title(3) + ", " + Title(4)
                                End If

                            ElseIf attribute.Name = "telephoneNumber" Then

                                'Set Telephone to the telephoneNumber attribute value from ldap.company.com
                                OutputBuffer.Telephone = attribute(i).ToString()


                            ElseIf attribute.Name = "PSCareerC1" Then

                                'Set PSCareerC1 to the PSCareerC1 attribute value from ldap.company.com
                                OutputBuffer.PSCareerC1 = attribute(i).ToString()

                            ElseIf attribute.Name = "PSCareerDescC1" Then

                                'Set PSCareerDescC1 to the PSCareerDescC1 attribute value from ldap.company.com
                                OutputBuffer.PSCareerDescC1 = attribute(i).ToString()

                            ElseIf attribute.Name = "PSProgC1" Then

                                'Set PSProgC1 to the PSProgC1 attribute value from ldap.company.com
                                OutputBuffer.PSProgC1 = attribute(i).ToString()

                            ElseIf attribute.Name = "PSExpTermC1" Then

                                'Set PSExpTermC1 to the PSExpTermC1 attribute value from ldap.company.com
                                OutputBuffer.PSExpTermC1 = attribute(i).ToString()

                            ElseIf attribute.Name = "PrimaryAffiliation" Then

                                'Set PrimaryAffiliation to the PrimaryAffiliation attribute value from ldap.company.com
                                OutputBuffer.PrimaryAffiliation = attribute(i).ToString()

                            ElseIf attribute.Name = "PrincipalName" Then

                                'Set PrincipalName to the PrincipalName attribute value from ldap.company.com
                                OutputBuffer.PrincipalName = attribute(i).ToString()

                            ElseIf attribute.Name = "OrgUnit" Then

                                'Set OrgUnit to the OrgUnit attribute value from ldap.company.com
                                OutputBuffer.OrgUnit = attribute(i).ToString()

                            ElseIf attribute.Name = "Affiliation" Then

                                If String.IsNullOrEmpty(Affiliations(0)) Then
                                    Affiliations(0) = attribute(i).ToString()
                                    OutputBuffer.Affiliations = Affiliations(0)
                                ElseIf String.IsNullOrEmpty(Affiliations(1)) Then
                                    Affiliations(1) = attribute(i).ToString()
                                    OutputBuffer.Affiliations = Affiliations(0) + ", " + Affiliations(1)
                                ElseIf String.IsNullOrEmpty(Affiliations(2)) Then
                                    Affiliations(2) = attribute(i).ToString()
                                    OutputBuffer.Affiliations = Affiliations(0) + ", " + Affiliations(1) + ", " + Affiliations(2)
                                ElseIf String.IsNullOrEmpty(Affiliations(3)) Then
                                    Affiliations(3) = attribute(i).ToString()
                                    OutputBuffer.Affiliations = Affiliations(0) + ", " + Affiliations(1) + ", " + Affiliations(2) + ", " + Affiliations(3)
                                ElseIf String.IsNullOrEmpty(Affiliations(4)) Then
                                    Affiliations(4) = attribute(i).ToString()
                                    OutputBuffer.Affiliations = Affiliations(0) + ", " + Affiliations(1) + ", " + Affiliations(2) + ", " + Affiliations(3) + ", " + Affiliations(4)
                                End If

                            End If
                        End If
                    Next

                Next
                counter = counter + 1
            Next
        End If
    End Using
End Sub

End Class
4

1 回答 1

-1

错误提示“超出大小限制”。

  • 可能有人更改了您的 AD:s MaxPageSize
  • 可能是您使用具有不同访问权限的不同帐户 OU:s
  • 可能是 MaxPageSize = 1000。当您执行 Apachesearch 时,浏览器可能有分页(很可能)

无论哪种方式,错误都会告诉您您必须使用分页搜索。您可以谷歌并了解如何操作。

旁注:在 AD 中,最好在过滤器中使用 ObjectCategory,因为它已被索引:

"(&(objectClass=user)(objectCategory=person))" 
于 2013-08-11T23:36:03.630 回答