Следующий код работает только в том случае, если в IIS включена только проверка подлинности Windows для локальных пользователей в нашей сети.Получение UserPrincipal с аутентификацией Windows и анонимной аутентификацией на
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, userName);
return up;
}
В противном случае он выдает это исключение:
[ArgumentException: The (& (ObjectCategory = пользователь) (объектный = пользователь) (| (UserPrincipalName =) (DistinguishedName =) (имя =))) фильтр поиска недействительна.] System.DirectoryServices.ResultsEnumerator.MoveNext() +434305 System.DirectoryServices.SearchResultCollection.get_InnerList() +282 System.DirectoryServices.SearchResultCollection.get_Count() +9 System.DirectoryServices.AccountManagement. ADStoreCtx.FindPri ncipalByIdentRefHelper (тип principalType, String urnScheme, String urnValue, DateTime referenceDate, Boolean useSidHistory) +1898 System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef (тип principalType, String urnScheme, String urnValue, DateTime referenceDate) +85 System.DirectoryServices.AccountManagement .Principal.FindByIdentityWithTypeHelper (PrincipalContext контекст, тип principalType, Nullable`1 IdentityType, String identityValue, DateTime refDate) +211 System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity (PrincipalContext контекст, String 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 (отправитель объекта, EventArgs e) в 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 (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
есть ли способ получить эту работу для получение наших локальных пользователей UserPrincipal , в то время как Windows и анонимная аутентификация включены?