【问题标题】:Accessing AD (active directory) Properties访问 AD(活动目录)属性
【发布时间】:2012-02-06 11:31:24
【问题描述】:

我通过以下方法访问 AD 属性。它在我的本地 VHD(我是域/本地/企业管理员)中工作正常 - 但当我从域用户(只有本地管理员访问权限)访问时,同样不起作用。

但同一域用户(仅具有本地管理员访问权限)使用 ADExplorer(SysInternal) 工具访问所有 AD 属性详细信息。

是不是因为那是非托管代码并且有 Windows API 可以访问,并且在 .Net 中我需要域管理员或一些特权?

或者是否有另一种方式 - 我在 .Net 中缺少这种方式来访问 AD 属性而无需额外的域级权限??

public void getCurrentUserADDetails(string UserName)
{
   string ladpQueryStr = "LDAP://sp.com";

   DirectoryEntry dirEntry = new DirectoryEntry(ladpQueryStr);
   DirectorySearcher srch = new DirectorySearcher(dirEntry);

   srch.Filter = "(cn=" + UserName.ToLowerInvariant().Trim() + ")";

   srch.PropertiesToLoad.Add("name");
   srch.PropertiesToLoad.Add("memberOf");
   srch.PropertiesToLoad.Add("prop123");

   SearchResult searcResult = srch.FindOne();

   if (searcResult != null)
   {
      ResultPropertyCollection propertiesCollection = searcResult.Properties;

      List<DisplayClass> grdDataList = new List<DisplayClass>();

      foreach (string strKey in propertiesCollection.PropertyNames)
      {
         DisplayClass dispC = new DisplayClass();
         dispC.pName = strKey;
         dispC.pValue = Convert.ToString(propertiesCollection[strKey][0]);

         grdDataList.Add(dispC);
      }

      dataGridView1.DataSource = grdDataList;
   }
}

这将在 ASP.Net 中运行

提前致谢:)

【问题讨论】:

  • 您能否将您遇到的异常发布给域用户(非管理员)?
  • 拥有 AppPool 的用户是否有权访问 AD?

标签: c# asp.net .net .net-3.5 active-directory


【解决方案1】:

我假设您正在使用集成身份验证 - 为了使其工作,您必须设置帐户委派,除非您在域控制器上运行您的应用程序。这是一个相当棘手的过程,但 Google 中有大量信息。

【讨论】:

    【解决方案2】:

    通过使用显式身份验证并更改搜索过滤器,我得到了结果。

    DirectoryEntry dirEntry = new DirectoryEntry(路径, 用户名, 密码, AuthenticationType);

    【讨论】:

      猜你喜欢
      • 2010-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多