简体   繁体   English

使用SSIS - 查询活动目录的源

[英]Using SSIS - sources for querying active directory

I'm using SSIS to access the ldap server. 我正在使用SSIS访问ldap服务器。 After playing around a bit I managed to create a OLE-DB- connection (Can't use the ADO.NET connection). 玩了一下后我设法创建了一个OLE-DB连接(不能使用ADO.NET连接)。 The most crucial part about the connection itself (in the connection manager) is that I leave out the "server", thus that field is blank as the server can switch. 关于连接本身(在连接管理器中)最关键的部分是我省略了“服务器”,因此该字段是空白的,因为服务器可以切换。 The provider is the .Net Providers for OleDb\\OLE DB Provider for Microsoft Directory Services. 提供程序是用于Microsoft目录服务的OleDb \\ OLE DB提供程序的.Net提供程序。

That works so far with the following command then being used in the source: 到目前为止,使用以下命令,然后在源中使用:

SELECT extensionAttribute2 FROM 'LDAP://Mydonaimname' WHERE objectClass='User'

Now comes the strange part and also my question: 现在是奇怪的部分,也是我的问题:

When I'm using ADO NET Source the above statement with the mentioned connection works BUT I get a warning as extensionAttribute2 is of type System.object which ADO NET Source does not support. 当我使用ADO NET Source时,上面提到的连接的语句工作但是我得到一个警告,因为extensionAttribute2是System.object类型,ADO NET Source不支持。 The preview is correct though. 但是预览是正确的。

When I try the same statement and connection with a OLE DB Source I get an OLE DB Error (sadly no useful description is given in the error message only general error with 0x0 as error code) when I try to see the preview. 当我尝试相同的语句和与OLE DB源的连接时,我得到一个OLE DB错误(遗憾的是在错误消息中没有给出有用的描述只有一般错误,0x0作为错误代码)当我尝试查看预览时。 Despite looking around and trying I did not find anything there so my question is: 尽管四处寻找并尝试我没有找到任何东西,所以我的问题是:

  1. Is there any way to get OLE DB Source working ? 有没有办法让OLE DB Source工作?
  2. If not then is there a way to get the warning in ADO NET Source to disappear? 如果没有那么有没有办法让ADO NET Source中的警告消失?

I have used several sources to try to get data as you wrote (I don't have staight access to AD): 我已经使用了几个来源来尝试获取数据(我没有对AD的直接访问权限):

Processing Active Directory Information in SSIS - used first example 在SSIS中处理Active Directory信息 - 使用第一个示例

Universal Connector Integration Details - gave me examples of what I can get 通用连接器集成详细信息 - 给了我可以获得的示例

So using first example: 所以使用第一个例子:

1) I have created OLE DB Connection Manager . 1)我创建了OLE DB Connection Manager Selected provider Native OLE DB/OLE DB Provider for Microsoft Directory Services and added my server name; Native OLE DB/OLE DB Provider for Microsoft Directory Services选择提供程序本Native OLE DB/OLE DB Provider for Microsoft Directory Services并添加了我的服务器名称;

2) Create variable var1 as Object; 2)创建变量var1作为Object;

3) Then dragged Execute SQL task . 3)然后拖动Execute SQL task Opened editor: selected Full result set for ResultSet , Direct input for SQLSourceType , set BypassPrepare to True ; 打开的编辑器:为ResultSet选择Full result set ,为SQLSourceType Direct input ,将BypassPrepare设置为True ; selected Connection created in first step; 选择第一步创建的Connection ; gave SqlStatement : 给了SqlStatement

SELECT ExtensionAttribute2 FROM 'LDAP://eurolith-dc' WHERE objectClass='User'

Also tested with this because I don't have any 也测试了这个,因为我没有
SELECT cn FROM 'LDAP://eurolith-dc' WHERE objectClass='User'

Also in Result Set tab added variable created in step 2 and set Result Name = 0 ; 同样在Result Set选项卡中添加了在步骤2中创建的变量并设置Result Name = 0 ;

3) Created another variable Variable as data type Object, will use later for view; 3)创建另一个变量Variable作为数据类型Object,稍后将用于视图;

4) To show result I used Foreach Loop Container and Script task . 4)为了显示结果,我使用了Foreach Loop ContainerScript task In the Foreach Loop Container I changed Enumerator to Foreach ADO Enumerator and selected ADO object source variable as var1 . Foreach Loop Container我将Enumerator更改为Foreach ADO Enumerator并将选定的ADO object source variable更改为var1 Also mapped variable to new created Variable and Index=0 . 还将映射变量映射到新创建的VariableIndex=0 Inside this container I dragged Script task . 在这个容器里面我拖了Script task In the editor I have selected ReadOnlyVariables=User::Variable . 在编辑器中,我选择了ReadOnlyVariables=User::Variable Opened script and pasted this code: 打开脚本并粘贴此代码:

    String localVar = Convert.ToString(Dts.Variables["User::Variable"].Value);
    if (!String.IsNullOrEmpty(localVar))
    {
        MessageBox.Show(Dts.Variables["User::Variable"].Value.ToString());
    }

I am checking if variable is NULL, because I think I don't have any info in ExtensionAttribute2 . 我正在检查变量是否为NULL,因为我认为我在ExtensionAttribute2没有任何信息。 So I have checked with cn . 所以我用cn检查过。

This example worked for me. 这个例子对我有用。

And I guess, that you also have some NULL values for ExtensionAttribute2 and that why you got error. 我想,你也有一些ExtensionAttribute2 NULL值,以及你为什么会出错。 Try to check with cn and you will see. 尝试用cn检查,你会看到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM