【问题标题】:Access denied when get IIS DirectoryEntry in .net在 .net 中获取 IIS DirectoryEntry 时访问被拒绝
【发布时间】:2012-04-19 06:20:22
【问题描述】:

当我尝试创建一个新的 IIS DirectEntry 时,我总是拒绝访问,这是代码:

DirectoryEntry entry=new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
foreach(DirectoryEnetry de in entry.Children){
 Console.WriteLine(de.Name);
}

当前登录系统的用户已经是系统的超级管理员。

所以他应该拥有所有的权限。

如何解决?

顺便说一句,我在 asp.net Web 应用程序和窗口窗体应用程序中测试了代码,它们都抛出了相同的“拒绝访问”异常。

【问题讨论】:

    标签: asp.net iis active-directory


    【解决方案1】:

    您需要将 LDAP 服务器的凭据提供到您的 DirectoryEntry() 对象中。或者,您需要确保您的应用程序池指的是域帐户,而不是 NETWORKSERVICES 或其他应用程序池帐户,因为它们无权访问 AD。

    DirectoryEntry rootDSE = new DirectoryEntry("LDAP://yourldapserver");
    rootDSE.Username = "user";
    rootDSE.Password = "password";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-23
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 2014-11-14
      相关资源
      最近更新 更多