问题描述
对 System.DirectoryServices的重复表示歉意.DirectoryServicesCOMException:发生操作错误,但我还不能发表评论,也没有答案.
Apologies for duplicate of System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred but I can't comment yet and there's no answer.
此问题的解决方案无效.发布错误:System.DirectoryServices.DirectoryServicesCOMException
The solution from this question, did not work. Error on publishing: System.DirectoryServices.DirectoryServicesCOMException
我在Visual Studio 2010中有了一个带有Razor视图引擎的新ASP.NET MVC 3 Web应用程序项目.它是通过在主控制器和 System中添加两行代码而生成的.DirectoryServices.AccountManagement
参考已添加到项目中.
I've got a new ASP.NET MVC 3 web application project with Razor view engine in Visual Studio 2010. It is as generated with the addition of two lines of code added to the home controller and the System.DirectoryServices.AccountManagement
reference added to the project.
这在我的本地PC上运行正常,但是在我创建的Windows 2008 R2 IIS 7.5站点上出现错误.
This runs just fine on my local PC, but I get an error on a Windows 2008 R2 IIS 7.5 site I've created.
该站点使用 defaultAppPool
,它使用的是 ApplicationPoolIdentity
.根站点文件夹已被授予 IUSR
和 IIS AppPool \ DefaultAppPool
的读取权限.
The site uses the defaultAppPool
, which is using ApplicationPoolIdentity
. The root site folder has been granted IUSR
and IIS AppPool\DefaultAppPool
read permissions.
控制器中的两行代码是:
The two lines of code in the controller are:
PrincipalContext context = new PrincipalContext(ContextType.Domain);
ViewBag.name = UserPrincipal.FindByIdentity(context, User.Identity.Name).DisplayName;
我得到的错误是:
堆栈跟踪:
很好,这是我的第一个问题!
Be nice, it's my first question!
推荐答案
这很可能是权限问题.检查运行应用程序池的帐户是否具有执行这些Active Directory调用的权限.如果它是本地计算机帐户,则可能不会.
Most likely this is a permissions issue. Check that the account the App Pool is running under has the authority to perform these Active Directory calls. If it's a local machine account, it probably won't.
您可以在此处找到更多信息: http://msdn.microsoft.com/zh-CN/library/ms180891(v=vs.80).aspx
You can find more information here: http://msdn.microsoft.com/en-US/library/ms180891(v=vs.80).aspx
这篇关于UserPrincipal对象,Active Directory查询:DirectoryServicesCOMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!