【问题标题】:Access denied while update Active Directory object更新 Active Directory 对象时拒绝访问
【发布时间】:2013-12-09 17:15:56
【问题描述】:

我有一个针对 Active Directory 进行 Windows 身份验证的应用程序 (MVC4)。 用户登录后(通过浏览器登录对话框),他会获取包含他的数据的页面,他可以在其中更新它,例如电子邮件地址。

用户单击保存按钮后,他收到“访问被拒绝”错误,但他在 Active Directory 中具有适当的权限。

我用这样的代码保存用户数据:

using (DirectoryEntry de = new DirectoryEntry (path))
{
    SetEntityPropertyValue(de, "mail", user.Email);
    de.CommitChanges();
}

但是,如果我传递这个登录用户的用户名和密码,像这样:

using (DirectoryEntry de = new DirectoryEntry (path, user, password))
{
    SetEntityPropertyValue(de, "mail", user.Email);
    de.CommitChanges();
}

它有效。怎么了? 如果这不是自动发生的,如何从 Windows 身份验证中获取用户凭据以将其传递给 DirectoryEntry() 方法?

我之前没有写过,但是 IIS 和 AD 运行在不同的机器上。

【问题讨论】:

  • xiyal,你找到答案了吗?我正在与同样的问题作斗争。

标签: asp.net-mvc active-directory windows-authentication


【解决方案1】:

我认为您最初使用 IIS 应用程序池身份对 Active Directory 进行身份验证,该身份没有足够的权限写入 Active Directory,但确实有足够的权限从 AD 读取项目。相反,我认为您正在寻找 impersonation,这将使应用程序以经过身份验证的 Windows 用户身份运行。

尝试将此添加到您的 web.config。

<configuration>
  <system.web>
    <identity impersonate="true"/>
  </system.web>
</configuration>

当然,这将要求被模拟的 Windows 用户也有足够的权限来写入 Active Directory。

【讨论】:

  • 感谢您的回复!但是我之前尝试过设置模拟但没有成功。 IIS 和 AD 在不同的机器上运行,当我使用模拟时,我无法进行身份验证 - 登录对话框一遍又一遍地显示:/
  • 展位在同一个域中。
  • @xiyal 啊,我想知道你是否成为双跳问题的受害者。要解决它,您可能需要让 Active Directory 管理员参与其中。 blogs.technet.com/b/askds/archive/2008/06/13/… 和/或 blogs.technet.com/b/taraj/archive/2009/01/29/…
猜你喜欢
  • 1970-01-01
  • 2018-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多