c# - Windows XP 上出现PrincipalServerDownException,但 Windows 7 上没有

标签 c# windows-7 active-directory windows-xp principalcontext

我们有一个完全信任运行的 WPF 应用程序。

应用程序的一部分会检查 Windows AD 组的成员资格。

这在 Windows 7 计算机上运行良好,但在 Windows XP 计算机上则不行。

错误发生在以下行:

PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain name");

最佳答案

根据文章Managing Directory Security Principals in the .NET Framework 3.5 ,可能不需要“域名”变量。也就是说,如果您访问与应用程序位于同一域中的 Active Directory,则不需要域名。

You use the name parameter on the PrincipalContext constructor in order to provide the name of the specific directory to connect to. This can be the name of a specific server, machine, or domain. It's important to note that if this parameter is null, AccountManagement will attempt to determine a default machine or domain for the connection based on your current security context.

问题的解决方案或解决方法(至少在 XP 和 W7 上对我有用)是以下更改:

PrincipalContext ctx = new PrincipalContext(ContextType.Domain, null);

关于c# - Windows XP 上出现PrincipalServerDownException,但 Windows 7 上没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10894031/

相关文章:

c# - 如何引用和上传Azure Blob存储中的文件?

c# - 通过 queryString 上传文件/保存,无需文件上传控件

c# - 如何编写我的 WinForms 应用程序以播放系统声音?

powershell - 从电子表格更新 Active Directory

c# - 如何确定帐户的类型(AD 用户与 AD 组)?

java - 使用访问策略向用户配置 Active Directory 帐户时出错

c# - 当调用 Flush() 时,NLog 是否应该刷新 AsyncTargetWrapper 中所有排队的消息?

c# - 如何在 MainPage 中调用异步方法

amazon-web-services - 在 Windows/Cygwin 上配置 AWS SSH key

python - Python 中的 Windows 7 MARGINS 结构