다음 코드는 우리 네트워크의 로컬 사용자에 대해 IIS에서 Windows 인증 만 사용하는 동안에 만 작동합니다.Windows 인증 및 익명 인증을 사용하여 UserPrincipal을 가져 오는 중
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, userName);
return up;
}
그렇지 않으면이 예외가 발생 :
[ArgumentException이 다음 (& (수 objectcategory = 사용자() 방법 objectClass = 사용자() | (userPrincipalName 사용 =()에 distinguishedName =) (NAME =))) 검색 필터가 유효하다.] System.DirectoryServices.ResultsEnumerator.MoveNext() 434,305 System.DirectoryServices.SearchResultCollection.get_InnerList() 282 System.DirectoryServices.SearchResultCollection.get_Count() +9 System.DirectoryServices.AccountManagement. ADStoreCtx.FindPri ncipalByIdentRefHelper (유형 principalType, 문자열 urnScheme, 문자열 urnValue, 날짜 시간 referenceDate, 부울 useSidHistory) 1898 System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef (유형 principalType, 문자열 urnScheme, 문자열 urnValue, 날짜 시간 referenceDate) 85 System.DirectoryServices.AccountManagement .Principal.FindByIdentityWithTypeHelper (PrincipalContext 상황, 유형 principalType, Nullable`1 identityType, 문자열 identityValue, 날짜 시간 refDate) 211 System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity (PrincipalContext 컨텍스트, 문자열 identityValue) 95 WebApplication1.Index.GetUserPrincipal (String userName) C : \ Users \ xxx \ Documents \ Visual Studio 2010 \ Projects \ WebApplication1 \ WebApplication1 \ Index.aspx.cs : 38 WebApplication1.Index.Page_Load (Object sender, EventArgs e) in C : \ Users \ xxx \ Documents \ Visual Studio 2010 \ Projects \ WebApplication1 \ WebApplication1 \ Index.aspx.cs : 19 System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) + 25 System.Web.UI.Control.LoadRecursive() 71 System.Web.UI.Page.ProcessRequestMain (부울 includeStagesBeforeAsyncPoint, 부울 includeStagesAfterAsyncPoint)
3064은 작동이를 얻는 방법이 있나요 로컬 사용자 UserPrincipal 을 얻는 동안 Windows 및 익명 인증은 모두으로 설정되어 있습니까?