从 SQL Server 查询 LDAP 问题

发布于 2024-12-19 17:37:15 字数 825 浏览 0 评论 0原文

我在配置 SQL 语句以从 SQL Server 对 LDAP 执行 openquery 时遇到一些问题。我按照此处列出的说明进行操作:从 SQL Server 2005 查询 Active Directory 但我在将最后的部分组合在一起时遇到了一些麻烦。

首先,我不知道我的 LDAP 服务器在哪里。因此,我进行了 nslookup 并发现默认服务器为:

abc.domain.popo.local

我将我的 OPENQUERY 配置为

SELECT * FROM OPENQUERY( ADSI, 'SELECT * FROM ''LDAP://DC=abc,DC=domain,DC=popo,DC=local'' WHERE
objectCategory = ''User''')   

但是,我收到一条错误消息

准备查询“SELECT * FROM 'LDAP://DC=abc,DC=domain,DC=popo,DC=local' WHERE objectCategory = 'User'”以针对 OLE DB 提供程序“ADSDSOObject 执行”时出错" 对于链接服务器“ADSI”。

这里可能存在什么问题?我是否错误地设置了 DC(因为我什至不知道 DC 的含义)?或者更有可能是我的 LDAP 服务器完全错误?

I'm having some trouble configuring a SQL statement to perform an openquery on LDAP from SQL Server. I followed the instructions as laid out here: Querying Active Directory from SQL Server 2005 but I'm having some trouble putting the final pieces together.

Firstly, I didn't know where my LDAP server was. So I did a nslookup and found the default server as:

abc.domain.popo.local

I configured my OPENQUERY as

SELECT * FROM OPENQUERY( ADSI, 'SELECT * FROM ''LDAP://DC=abc,DC=domain,DC=popo,DC=local'' WHERE
objectCategory = ''User''')   

However, I get an error saying that

An error occurred while preparing the query "SELECT * FROM 'LDAP://DC=abc,DC=domain,DC=popo,DC=local' WHERE objectCategory = 'User'" for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI".

What is the likely issue here? Am I setting up the DC incorrectly (because I don't even know what DC means)? Or is it more likely that I just have the wrong server altogether for LDAP?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蒲公英的约定 2024-12-26 17:37:15

在我看来,您似乎正在尝试查询 Windows Active Directory(功能上显示为 LDAP)。默认情况下,AD 不允许匿名查询 - 您必须使用受信任的用户名和密码进行身份验证。此外,您需要咨询系统管理员以确保您具有正确的基值(“DC=abc,DC=domain,DC=popo,DC=local”)。

It looks to me like you're trying to query against a Windows Active Directory (which functionally appears as LDAP). By default, AD will not allow anonymous querying - you have to authenticate with a trusted username and password. Also, you need to check with your sysadmin to make sure you have the proper base value ("DC=abc,DC=domain,DC=popo,DC=local").

℡寂寞咖啡 2024-12-26 17:37:15

请参阅 Richard Mueller 的 ADO / SQL 搜索提示 - 它们有帮助吗? (Richard 的网站是 LDAP 和 Active Directory 参考资料和技巧的真正宝库 - 强烈推荐!)

从我在此网站上看到的情况来看,您可能使用了错误的 objectCategory - 尝试使用 Person 而不是 User (我相信它是一个 objectClass):

SELECT * FROM OPENQUERY(ADSI, 
            'SELECT * FROM ''LDAP://DC=abc,DC=domain,DC=popo,DC=local'' 
             WHERE objectCategory = ''Person''')   

See Richard Mueller's ADO / SQL search tips - do they help? (Richard's site is a real treasure trove of LDAP and Active Directory references and tips - highly recommended!)

From what I've seen on this site, you might be having the wrong objectCategory - try using Person instead of User (which I believe is an objectClass):

SELECT * FROM OPENQUERY(ADSI, 
            'SELECT * FROM ''LDAP://DC=abc,DC=domain,DC=popo,DC=local'' 
             WHERE objectCategory = ''Person''')   
不醒的梦 2024-12-26 17:37:15

确保“abc”不是该域中域控制器的实际名称;因此,在这种情况下,您的 OPENQUERY 应忽略该内容并为:

SELECT * FROM OPENQUERY( ADSI, 'SELECT * FROM ''LDAP://DC=domain,DC=popo,DC=local'' WHERE objectCategory = '' Person'' AND objectClass = ''用户''')

Make sure that "abc" isn't the actual name of a domain controller in that domain; hence in that case your OPENQUERY should omit that and be:

SELECT * FROM OPENQUERY( ADSI, 'SELECT * FROM ''LDAP://DC=domain,DC=popo,DC=local'' WHERE objectCategory = ''Person'' AND objectClass = ''user''')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文