2013-06-17 2 views
2

Active Directory에서 읽고 쓰는 웹 응용 프로그램을 만들었습니다. 내가 어떤 라벨에ASP.NET - 코드 숨김 페이지에서 Active Directory 액세스

System.Web.HttpContext.Current.User.Identity.Name 

을 표시 할 때 내 web.config 파일에서

<identity impersonate="true"/> 

<authentication mode="Windows"/> 

있다, 그것은 mydomain\myusername을 보여줍니다, 그래서 가장의 일을 생각한다.

지금 질문드립니다. IIS 웹 서버가 실행되는 서버의 응용 프로그램에 액세스하면 모든 것이 잘 작동합니다. 그러나 원격 PC에서 웹 응용 프로그램에 액세스하면 예외가 발생합니다 (레이블에는 여전히 "mydomain \ myusername"이 표시됨).

나는이 문제를 추적했다. 내가

Forest currentForest = Forest.GetCurrentForest(); 

변수 currentForest

System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException.

currentForest.Name, currentForest.RootDomain 또는 currentForest.ForestMode하지만 currentForest.Domains에 대한 호출, currentForest.Sites 또는 currentForest.GlobalCatalogs 결과를 알고 전화 할 때 뒤에있는 코드에서 지금은 손실과 돈이야 더 이상 디버깅 할 것을 알지 못합니다. 사용중인 계정이 Enterprise Admins (다중 도메인 포리스트)의 구성원입니다. 나는 행운이없이 다른 IIS 버전 (IIS 7.5 및 IIS 6.0)을 사용하는 두 개의 다른 서버에서이 서버를 시험해 보았습니다.

그리고 던져진 예외는 많은 도움이되지 않습니다 :

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred.
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
DirectoryServicesCOMException (0x80072020): An operations error occurred.

System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +557
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +98
System.DirectoryServices.ActiveDirectory.ADSearcher.FindAll() +46
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +543

[ActiveDirectoryOperationException: An operations error occurred.]

System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +512484
System.DirectoryServices.ActiveDirectory.Forest.get_Domains() +44
myWebApp.ASPpage.Button_Click(Object sender, EventArgs e) in C:\Documents and Settings\myUser\documents\visual studio\Projects\MyWebApp\MyWebApp\ASPPage.aspx.cs:158
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

편집 : 그것은 분명하지 않은 경우, 나는 주어진 사용자의 숲 전체 (모든 도메인)을 검색 할 currentForest.Domains를 사용하려면 UPN 이름으로.

답변

0

이 질문에 대한 답변은이 페이지의 "관련 질문"에 있습니다. 이 주제에 대한 대답은 Why does DirectoryServicesCOMException occur querying Active Directory from a machine other than the web server?

입니다. 제안 된 Microsoft 기사를 읽은 후, 가장 한 것은 IIS 서버의 로컬 리소스에 대해서만 작동한다는 것을 알았습니다. 네트워크 리소스 (SQL, Active Directory)에 액세스하려면 Active Directory의 컴퓨터 개체에서 "위임을 위해이 컴퓨터 트러스트"를 설정해야합니다. System.Security.Principal.WindowsIdentity.GetCurrent().Name, 그것은 가장하고 있지 않은 경우도 System.Security.Principal.WindowsIdentity.GetCurrent(true) 반환 널 (null) 값 : IIS 항상 System.Web.HttpContext.Current.User.Identity.Name이 가장 당신이 사용할 수있는 작동하는지 확인하기 위해 mydomain\myusername;을 보여줍니다 때문에 인증 때문에

관련 문제