PrincipalContext-我无法连接到本地openldap服务器 [英] PrincipalContext - I Can't connect to a local openldap server

查看:275
本文介绍了PrincipalContext-我无法连接到本地openldap服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了openldap for windows服务器,并使用LDAPAdmin通过其默认值连接到服务器:

I have installed an openldap for windows server and I use LDAPAdmin to connect to it by its default values :

Server=ldap://localhost:389
Base:dc=maxcrc,dc=com
UserName:cn=Manager,dc=maxcrc,dc=com
Password:secret

现在我要使用PrincipalContext将用户添加到我的ou=People 问题是我什至无法使用PrincipalContext连接到服务器.我已经在网上搜索了很多关于如何连接到ldap服务器的答案,但是没有一个对我有用.我不断为PrincipalContext构造函数提供的参数的不同组合得到一个NullReferenceExceptionServerNotFoundException. 我以为可以将PrincipalContext用作以下内容之一:

Now I want to use PrincipalContext to add users to my ou=People The problem is I can't even connect to the server using PrincipalContext. I have searched the Net and found a lot of answers on how to connect to a ldap server but none of them are working for me.I keep getting a NullReferenceException or ServerNotFoundException for different combination of provided parameters for PrincipalContext constructor. I thought I could use PrincipalContext as one of the follows :

new PirncipalContext(ContextType.Domain,"maxcrc.com","dc=maxcrc,dc=com")

new PrincipalContext(ContextType.ApplicationDirectory,"localhost:389","dc=maxcrc,dc=com")

但是它们都不起作用.有人说我应该提供用户名和密码,所以我这样做了,但是我一直在例外.

but none of them are working.Some say that I should provide username and password so I did that but I keep getting exception.

所以请告诉我如何使用PrincipalContext连接到openldap?

So please tell me how can I use PrincipalContext to connect to openldap ?

P.S.我的计算机已经加入了Active Directory域控制器.

P.S. My computer is already joined to an Active Directory domain controller.

推荐答案

作为

System.DirectoryServices.AccountManagement命名空间为跨多个主体存储的用户,计算机和组安全主体提供统一的访问和操作: Active Directory 域服务(AD DS), Active Directory 轻型目录服务(AD LDS)和计算机SAM(MSAM). System.DirectoryServices.AccountManagement管理与System.DirectoryServices命名空间无关的目录对象.

The System.DirectoryServices.AccountManagement namespace provides uniform access and manipulation of user, computer, and group security principals across the multiple principal stores: Active Directory Domain Services (AD DS), Active Directory Lightweight Directory Services (AD LDS), and Machine SAM (MSAM). System.DirectoryServices.AccountManagement manages directory objects independent of the System.DirectoryServices namespace.

这些类仅对 Active Directory 有用-对其他通用" LDAP存储不可移植.

Those classes are useful for Active Directory only - they are not portable to other, "generic" LDAP stores.

如果需要支持OpenLDAP,请使用DirectoryEntry和这些功能,或使用较低级别的System.DirectoryServices.Protocol(裸LDAP)层.

If you need to support OpenLDAP, either use DirectoryEntry and those functions, or use the lower level System.DirectoryServices.Protocol (bare-bones LDAP) layer.

这篇关于PrincipalContext-我无法连接到本地openldap服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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