问题标签 [principalcontext]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
719 浏览

c# - 如何通过扩展 UserPrincipal 类在 Active Directory 中创建联系人?

我需要在 Active Directory 中创建一个联系人。我有一个扩展 UserPrincipal 的类。如何使用它来创建新联系人?下面的代码抛出 PrincipalOperationException “请求的操作不满足与对象类关联的一个或多个约束。” 例外。

我究竟做错了什么?

0 投票
1 回答
1993 浏览

c# - 建立上下文时如何设置连接超时 - PrincipalContext

我使用上面的 PrincipalContext 类来建立到目标目录的连接并指定凭据以对目录执行操作。

有谁知道我如何在 PrincipalContext 构造函数中指定连接超时?,我遇到了连接超时问题,我想知道我是否可以控制连接超时多长时间。

0 投票
1 回答
2096 浏览

c# - PrincipalContext - 我无法连接到本地 openldap 服务器

我已经安装了一个openldap for windows服务器,我用LDAPAdmin它的默认值连接到它:

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

或者

但他们都没有工作。有人说我应该提供用户名和密码,所以我这样做了,但我不断收到异常。

那么请告诉我如何使用 PrincipalContext 连接到 openldap ?

PS 我的电脑已经加入了一个 Active Directory 域控制器。

0 投票
0 回答
266 浏览

c# - 获取用户组对 LDAP 服务器的调用得到“服务器无法运行”,因为服务器调用了更改

我正在尝试使用以下方法从 ADAM 服务器获取用户组:

而且我不断收到“服务器无法运行”错误。

我终于明白了我的问题,但我不知道如何解决它。

问题是,两台 ADAM 服务器位于防火墙和 NLB 后面,它们都以 adam.company.local 的名称和该名称的 nslookup 回复,回复的 100.10.130.1

我什至可以 ping 100.10.130.1 和名称 adam.company.local 所以问题不在于网络,但它是!

使用 WireShark,我发现服务器有时会返回他自己的名字,而我的调用开始尝试调用该名字。当然,防火墙会阻止它们并发生异常。

为了确认这一点,我在 hosts 文件中创建了 2 行,将两个服务器名称都设置为 100.10.130.1 并且问题消失了,我可以轻松检索所有组。

这是为什么?为什么断开连接会更改为我无法访问的机器?

最后一个问题是如何防止它,因为在发布机器上我无法在主机文件上创建这些行?

0 投票
1 回答
63894 浏览

c# - 如何使用主体上下文连接到 Active Directory?

我已经有一段时间了,我总是得到:

System.DirectoryServices.AccountManagement.PrincipalServerDownException

我认为这意味着我的连接设置(连接字符串)是错误的。

当我在 Active Directory 所在的计算机上的 cmd 上编写“dsquery server”时,我得到:

"CN=DCESTAGIO,CN=SERVERS,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=estagioit,DC=local"

我通过以下方式尝试了以下连接:

1:

2:

3:

4:

5:

还有其他一些方法...

关于出了什么问题以及如何使这种连接起作用的任何想法?

PS:IP是正​​确的,因为我用它来ping它并且它正在工作。

PPS:如果您有任何建议,我真的,真的需要尽快工作,他们都欢迎。

0 投票
1 回答
406 浏览

c# - .NET c# 中 Active Directory 的变化

我正在为所有用户和组的活动目录之间的内部 .NET 应用程序之间进行同步。我从 Active Directory 中获取所有用户和组,并将这些数据保存在 .NET 应用程序数据库中。

我正在使用PrincipalContext对象进行 Active Directory 查询。我想确定是否更改用户或组以提供高性能。有什么办法吗?例如或对象的LastModifiedDate属性。GroupPrincipalUserPrincipal

0 投票
0 回答
118 浏览

c# - 如何使用具有密码哈希的目录服务 AccountManagement 对用户进行身份验证

如果我在上面的代码片段中传递了正确的密码,则身份验证工作正常,但假设我没有密码但我已获得密码哈希,我将如何仅在上面的行中使用哈希进行身份验证而不知道真正的密码字符串?

让我们假设密码哈希是使用此类创建的https://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx

或者,如果上述方法不可行,是否可以至少获取给定帐户的密码哈希,以便我可以将从 AD 返回的密码哈希与提供的哈希进行比较以检查它们是否匹配?

0 投票
1 回答
724 浏览

c# - 使用 PrincipalContext 时如何检查连接到服务器?

我需要更改连接在同一网络中的机器上的 windows 用户的密码。为此,我使用PrincipalContext方法连接机器,然后获取指定的用户,最后更改密码。

问题是,当我提供“ServerName”但与“ServerIp”一起使用时,有时我无法连接到服务器,反之亦然。如果已连接context.ConnectedServer将显示服务器名称,否则将显示未知路径或错误的用户名错误。

如果没有建立连接,我可以使用 serverIp 作为参数

为此,我试图if( context.ConnectedServer != serverName)知道连接不起作用并将上面的代码放入其中。但是由于没有 ConnectedServer,它将返回错误。

如何检查与服务器的连接是否建立?

0 投票
1 回答
1341 浏览

c# - Establish a connection to Active Directory using PrincipalContext under the security context of an external service

As seen in the code snippet above, i'm establishing a connection to Active Directory in a Domain by providing a UserName & Password in the PrincipalContext constructor.

After the connection is made, i query the connected Active Directory for FirstName and LastName.

If i do not pass in a UserName & Password, the PrincipalContext constructor will use the credentials of the account running the application pool hosting the asp.net application in IIS to connect to Active Directory.

But i'm wondering, if its possible to create some kind of service running under an account that has access to the domain being queried and then use that services hosting account information (username & password) to connect to AD instead of passing the username and passowrd directly as above.

Assuming some one deploys a service, say in IIS & that service is running under the context of account X and this account X has access to the domain i want to query, would it be possible to call that service in the PrincipalContext constructor such that i use the credentials under which the service is running under to connect to AD that i want to query.

My intention here would be not to provide the UserName & Password, but also avoid using the credentials that the application pool hosting the ASP.NET application is running under.

I want to establish a connection to AD using the security context of an external service.

0 投票
1 回答
717 浏览

asp.net-mvc - 需要澄清 PrincipalContext 安全权限和 PrincipalContext 的 ContextType.Machine

如果我使用上面的代码查询 Active Directory,并且在 PrincipalContext 构造函数中传递的用户名(帐户)位于与目标域(要查询的域)不信任的域中,我会收到以下错误。

System.DirectoryServices.AccountManagement.PrincipalServerDownException:无法联系服务器。---> System.DirectoryServices.Protocols.LdapException:LDAP 服务器不可用。

如果将 PrincipalContext 构造更改为,我是否正确?

只要客户端在目标域中,代码就会成功执行?

假设第一个带有 UserName 和 Password 的代码被域 A 中的客户端调用,试图在域 B 中搜索用户信息,这里建立上下文失败,因为使用的帐户在域 A 中,与域 B 不信任。

我是否正确假设如果我将 ContextType 更改为 Machine,并且调用代码的客户端位于域 B 中,代码将成功执行?