VB.Net-LDAP:超出了大小限制

VB.Net-LDAP:超出了大小限制,vb.net,ssis,active-directory,directory,ldap,Vb.net,Ssis,Active Directory,Directory,Ldap,我使用的脚本应该可以从LDAP中提取1400条记录(我通过在ApacheDirectory Studio中运行相同的过滤器进行了双重检查,查询成功运行)。输出将用作SSIS SQL源。我知道LDAP上的页面限制设置为2000,但是每次运行下面的脚本时,我们都会收到以下错误消息“超出了大小限制”。有人能看到我们的脚本中可以修改什么来克服这个错误消息吗?我尝试过设置“request.SizeLimit=Integer.MaxValue”并尝试过“request.SizeLimit=2000”,但是“

我使用的脚本应该可以从LDAP中提取1400条记录(我通过在ApacheDirectory 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
导入系统
导入系统数据
导入系统。数学
导入System.DirectoryServices.Protocols
导入Microsoft.SqlServer.Dts.Pipeline.Wrapper
导入Microsoft.SqlServer.Dts.Runtime.Wrapper
_
_
公共类ScriptMain
继承用户组件
公共覆盖子CreateNewOutputRows()
'设置将绑定到的ldap服务器字符串和端口号
Dim con作为新的LdapConnection(新的LdapDirectoryIdentifier(“ldap.company.com:636”))
'设置用于绑定ldap.company.com的服务帐户的用户名和密码
Dim凭据作为新的System.Net.NetworkCredential(“用户名”、“密码”)
'启用SSL环绑定到ldap.company.com
con.SessionOptions.SecureSocketLayer=True
'设置用于绑定到ldap.company.com的身份验证方法
con.AuthType=AuthType.Basic
'传递先前建立的凭据
con.Credential=凭证
利用骗局
'设置要从ldap.company.com提取的属性
Dim attributesToReturn As String()=新字符串(){“uid”、“companyID”、“givenName”、“昵称”、“中间名1”、“序列号”、“生成限定符”、“学位”、“显示名”、“邮件”、“PSCareerC1”、“PSCareerDescC1”、“PSProgC1”、“PSEXPERMC1”、“附属关系”、“主要附属关系”、“主要名称”、“电话号码”、“组织单位”、“标题”}
'针对ldap.company.com设置查询的搜索范围和筛选器
Dim请求作为新的SearchRequest(“OU=people,DC=company,DC=com”,“objectClass=person)”,SearchScope.Subtree,attributesToReturn)
作为SearchResponse=DirectCast的Dim响应(con.SendRequest(请求,新时间跨度(1,0,0,0)),SearchResponse)
'使用上面设置的参数将ldap绑定请求发送到ldap.company.com
con.Bind()
如果response.Entries.Count>0,则
作为整数的Dim计数器=0
'枚举每个条目,提取请求的每个属性
作为响应中的SearchResultEntry的每个条目
OutputBuffer.AddRow()
作为字符串的Dim关联(5)
Dim标题(5)作为字符串
OutputBuffer.DN=entry.DifferentiedName.ToString()
将属性设置为SearchResultAttributeCollection=entry.attributes
将每个属性作为attributes.Values中的DirectoryAttribute
对于属性为整数=0的i,计数为-1
如果属性(i)的类型为字符串,则
如果attribute.Name=“uid”,则
'从ldap.company.com将NetID设置为uid属性值
OutputBuffer.NetID=属性(i).ToString()
ElseIf attribute.Name=“givenName”则
'从ldap.company.com将FirstName设置为givenName属性值
OutputBuffer.FirstName=属性(i).ToString()
ElseIf attribute.Name=“昵称”然后
'从ldap.company.com将昵称设置为昵称属性值
OutputBuffer.昵称=属性(i).ToString()
ElseIf attribute.Name=“MiddleName1”则
'从ldap.company.com将MiddleName设置为MiddleName1属性值
OutputBuffer.MiddleName=属性(i).ToString()
ElseIf attribute.Name=“sn”然后
'从ldap.company.com将LastName设置为sn属性值
OutputBuffer.LastName=属性(i).ToString()
ElseIf attribute.Name=“generationQualifier”然后
'将后缀设置为ldap.company.com中的generationQualifier属性值
OutputBuffer.Suffix=属性(i).ToString()
ElseIf attribute.Name=“Degree”然后
'将Degree设置为ldap.company.com中的Degree属性值
OutputBuffer.Degree=属性(i).ToString()
ElseIf attribute.Name=“displayName”则
'将DisplayName设置为ldap.company.com中的DisplayName属性值
OutputBuffer.DisplayName=属性(i).ToString()
ElseIf attribute.Name=“companyID”则
'将UniqueID设置为ldap.company.com中的companyID属性值
OutputBuffer.UniqueID=属性(i).ToString()
ElseIf attribute.Name=“mail”则
'从ldap.company.com将电子邮件设置为邮件属性值
OutputBuffer.Email=属性(i).ToString()
ElseIf attribute.Name=“title”然后
OutputBuffer.Title=属性(i).ToString()
如果String.IsNullOrEmpty(标题(0)),则
标题(0)=属性(i).ToString()
"(&(objectClass=user)(objectCategory=person))"