从 SQL Server 查询 LDAP 问题
我在配置 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我看来,您似乎正在尝试查询 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").
请参阅 Richard Mueller 的 ADO / SQL 搜索提示 - 它们有帮助吗? (Richard 的网站是 LDAP 和 Active Directory 参考资料和技巧的真正宝库 - 强烈推荐!)
从我在此网站上看到的情况来看,您可能使用了错误的
objectCategory
- 尝试使用Person
而不是User
(我相信它是一个objectClass
):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 usingPerson
instead ofUser
(which I believe is anobjectClass
):确保“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''')