2

我正在從活動目錄訪問用戶信息。我的代碼在我的本地PC上運行良好(具有Windows XP,不在域中)。代碼是驗證機制未知

  PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domainName", "ActiveDirectoryID", "Password"); 

      UserPrincipal qbeUser = new UserPrincipal(ctx); 
      PrincipalSearcher srch = new PrincipalSearcher(qbeUser); 
      qbeUser.SamAccountName = "AnyOther_AD_ID"; //To get any one's info 
      foreach (var found in srch.FindAll()) 
      { 
       UserPrincipal foundUser = found as UserPrincipal; 
       if (foundUser != null) 
       { 
        emailAddress = foundUser.EmailAddress; 
       } 
      } 

但是,當我將我的應用程序部署到服務器pc(Windows Server 2003,域)。它給出錯誤「認證機制未知」。 打擊我的問題是服務器,即在域上不能訪問AD信息,但我的本地PC,即不在域上可以訪問AD信息(我給AD_Id和密碼)。

+0

我正在使用Windows身份驗證,並在web.config文件中將impersonate設置爲true。 – Lali 2011-12-21 13:48:36

回答

0

嘗試爲用戶原則或搜索者提供登錄憑據。我以前經歷過同樣的事情,如果我用我的AD連接​​用戶名&密碼它會工作。