简体   繁体   English

C#Active Directory主体上下文权限

[英]C# Active Directory Principalcontext Permissions

I've been searching for an answer and can't seem to find one, but maybe I missed it. 我一直在寻找答案,但似乎找不到答案,但也许我错过了。 I have a WPF application and I use PrincipalContext to connect to MS AD. 我有一个WPF应用程序,并且使用PrincipalContext连接到MS AD。 My development machine is not domain joined and I can connect no problem. 我的开发机器未加入域,因此我可以正常连接。 However, on our terminal server, my application can only connect if the currently logged in user is in the Domain Admins group, even though I am passing valid credentials to the PrincipalContext constructor. 但是,在终端服务器上,即使我将有效凭据传递给PrincipalContext构造函数,我的应用程序也只能在当前登录的用户位于Domain Admins组中时才能连接。 I have tried using my account, a 'service' account, and even the Administrator account. 我尝试使用我的帐户,“服务”帐户,甚至是管理员帐户。

I have this working on my development machine but not on our terminal server: 我在我的开发机器上工作,但不在我们的终端服务器上工作:

PrincipalContext pc = new PrincipalContext(ContextType.Domain, "DC.mydomain.com", null, ContextOptions.SimpleBind | ContextOptions.ServerBind, Username, Password);

On the terminal server, it throws an exception. 在终端服务器上,它将引发异常。 The message is "The connection cannot be established". 消息为“无法建立连接”。 Upon further investigation I found that LDAP is returning an error code of 91, which I have looked up as well, but I still cannot seem to get it to connect. 经过进一步调查,我发现LDAP返回的错误代码为91(我也已查找该错误代码),但似乎仍然无法连接它。 I must have tried passing every combination of parameters to PrincipalContext. 我必须尝试过将参数的每个组合传递给PrincipalContext。

Edit: 编辑:

I've been playing with it some more. 我已经在玩了。 I can't get PrincipalContextor LdapConnection to connect on the terminal server, but they both work on my development machine. 我无法让PrincipalContextor LdapConnection在终端服务器上进行连接,但是它们都可以在我的开发计算机上使用。 The only thing that will connect is DirectoryEntry. 唯一可以连接的是DirectoryEntry。 Maybe that will provide more clues? 也许会提供更多线索?

Any suggestions? 有什么建议么?

I managed to figure it out. 我设法弄清楚了。 It was some sort of permissions issue on the folder I was running the application from. 这是我从中运行应用程序的文件夹上的某种权限问题。 Hope this can help someone in the future. 希望这可以在将来对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Active Directory C# 中创建用户的 PrincipalContext 或 DirectoryEntry 哪个更好 - Which is better PrincipalContext or DirectoryEntry for user creation in Active Directory C# C# Active Directory PrincipalContext / UserPrincipal.IsMemberOf 错误 - C# Active Directory PrincipalContext / UserPrincipal.IsMemberOf error 使用 PrincipalContext 连接到活动目录 - Connect to active directory with PrincipalContext 用于在Active Directory中查询的PrincipalContext - PrincipalContext for query in Active Directory C#向Active Directory中的每个人授予权限 - C# Give Permissions to Everyone in Active Directory 通过C#继承Active Directory权限 - Inherit Active Directory permissions via C# 如何使用ASP.net,C#通过PrincipalContext在活动目录上添加Manager属性 - How to add Manager attribute on active directory by PrincipalContext using ASP.net,C# 是否有一个C#库,其行为类似于Active Directory的权限和组? - Is there a C# library that behaves like Active Directory's Permissions and Groups? 使用C#在Active Directory中创建新组并设置权限 - Creating a new group and setting permissions in Active Directory using C# Active Directory PrincipalContext.ValidateCredentials域消除歧义 - Active Directory PrincipalContext.ValidateCredentials domain disambiguation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM