使用 DirectoryServices 从 C# 连接到 LDAP [英] Connecting to LDAP from C# using DirectoryServices

查看:25
本文介绍了使用 DirectoryServices 从 C# 连接到 LDAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接到运行 LDAP 的 edirectory 8.8 服务器.我将如何在 .Net 中执行此操作?我仍然可以使用 System.DirectoryService 中的类,例如 DirectoryEntry 和 DirectorySearcher 还是它们是特定于 AD 的?我需要以不同的方式指定连接字符串"吗?

I am trying to connect to an edirectory 8.8 server running LDAP. How would I go about doing that in .Net? Can I still use the classes in System.DirectoryService such as DirectoryEntry and DirectorySearcher or are they AD specific? Do I need to specify the "Connection String" any differently?

我正在尝试类似下面的代码,但它似乎不起作用...

I am trying something like the code below but it doesn't seem to work...

DirectoryEntry de = new DirectoryEntry ("LDAP://novellBox.sample.com","admin","password",AuthenticationTypes.None);
DirectorySearcher ds = new DirectorySearcher(de);
var test = ds.FindAll();

有什么想法吗?

推荐答案

好吧,我认为您的连接字符串丢失了一点-仅指定服务器名称还不够好-您还需要指定起点"供您搜索.

Well, I think your connection string is missing a bit - specifying just the server name isn't good enough - you also need to specify a "starting point" for your search.

在 AD 中,这通常类似于您域中的用户"容器,您可以在 LDAP 用语中这样指定:

In AD, this would typically be something like the "Users" container in your domain, which you'd specify like this in LDAP parlance:

LDAP://novellBox.sample.com/cn=Users,dc=YourCompany,dc=com

不确定 eDirectory 的较新版本如何与 LDAP 兼容 - 但这应该可以工作,因为理论上它是标准 LDAP,无论实施如何 :-)

Not sure how LDAP compliant the newer versions of eDirectory are - but that should work since in theory, it's standard LDAP regardless of the implementation :-)

但话又说回来:只是理论上,理论和实践没有区别.....

But then again: only in theory, there's no difference between theory and practice.....

还有一个 System.DirectoryServices.Protocols 命名空间,它直接提供低级 LDAP 调用 - 这绝对与 AD 无关,但它确实非常低级......

There's also a System.DirectoryServices.Protocols namespace which offers low-level LDAP calls directly - and that's definitely not tied to AD at all, but it's really quite low-level.....

还有一个 Novell C# LDAP 库,但我从未尝试过它并且不能说它有多完整或有能力.不过,它可能会给你一些线索!

There's also a Novell C# LDAP library but I've never tried it and can't say how complete or capable it is. It might give you some clues, though!

另请参阅其他 Stackoverflow 问题 关于 Novell、LDAP 和 C# - 它可能会为您提供更多信息.

Also see this other Stackoverflow question about Novell, LDAP and C# - it might give you additional info.

这篇关于使用 DirectoryServices 从 C# 连接到 LDAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆