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

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

问题描述

我用来检查用户凭据的小C#的解决方案。它工作正常的两个我的队友,但我的电脑上我得到一个异常。

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.

相关code:

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.

任何想法?

推荐答案

我有这个问题:事情正在处理我的dev的机器,但在服务器上没有工作。原来,IIS服务器上的成立,为LOCALMACHINE运行。我改成了网络服务(默认值),事情开始工作。

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天全站免登陆