.Net 的目录服务抛出一个奇怪的异常 [英] .Net's Directory Services throws a strange exception

查看:21
本文介绍了.Net 的目录服务抛出一个奇怪的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于检查用户凭据的小型 C# 解决方案.它对我的两个队友运行良好,但在我的 PC 上却出现异常.

I have a small C# solution used to check users credentials. It works fine for two of my teammates, but on my PC I get an exception.

相关代码:

PrincipalContext context = new PrincipalContext(ContextType.Domain);
if (context.ValidateCredentials(System.Environment.UserDomainName + "\" + usr, pwd))
     return true;
else
     return false;

例外是:

DirectoryOperationException,服务器无法处理目录请求.".

DirectoryOperationException, "The server cannot handle directory requests.".

我尝试使用显式服务器名称和 636 端口号创建上下文,但这也无济于事.

I tried creating context with the explicit server name and the 636 port number, but this didn't help as well.

有什么想法吗?

推荐答案

我遇到了这个问题:我的开发机器上可以正常工作,但在服务器上却无法正常工作.原来服务器上的 IIS 被设置为作为 LocalMachine 运行.我将其更改为 NetworkService(默认设置),然后一切就开始工作了.

I had this issue: things were working on my dev machine but didn't work on the server. Turned out that IIS on the server was set up to run as LocalMachine. I changed it to NetworkService (the default) and things started working.

所以基本上检查应用程序池的用户是否在 IIS 上运行.

So basically check the user of the app pool if this is running on IIS.

这篇关于.Net 的目录服务抛出一个奇怪的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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