C# Dotnet core 2.2/IIS-广告访问问题

C# Dotnet core 2.2/IIS-广告访问问题,c#,iis-7.5,asp.net-core-2.2,C#,Iis 7.5,Asp.net Core 2.2,我有一个问题,我目前正在工作的应用程序,我希望你们中的一些人能够帮助我 我正在尝试从广告中获取有关登录用户的一些信息(通过windows身份验证) using (var context = new PrincipalContext(ContextType.Domain)) { var user = UserPrincipal.FindByIdentity(context, loginName); if (user == null) return new List<string>

我有一个问题,我目前正在工作的应用程序,我希望你们中的一些人能够帮助我

我正在尝试从广告中获取有关登录用户的一些信息(通过windows身份验证)

using (var context = new PrincipalContext(ContextType.Domain))
{
  var user = UserPrincipal.FindByIdentity(context, loginName);
  if (user == null) return new List<string>();
  var groups = user.GetGroups();
  return groups.Select(x => x.SamAccountName).ToList();
}

我使用的是dotnet core 2.2,应用程序托管在IIS 7.5上

请分享错误。您只有
at
stacktrace行,这些行指示了位置而不是原因。请向域管理员寻求帮助。应用程序池标识通常应设置为域服务帐户,然后它可以与AD对话并查询数据。
"ClassName": "System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException",
  "Message": "Une erreur locale s’est produite",
  "Data": null,
  "InnerException": {
    "ClassName": "System.DirectoryServices.DirectoryServicesCOMException",
    "Message": "Une erreur locale s’est produite",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)\r\n   at System.DirectoryServices.PropertyValueCollection.PopulateList()\r\n   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)\r\n   at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)\r\n   at System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName)",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": null,
    "HResult": -2147016645,
    "Source": "System.DirectoryServices",
    "WatsonBuckets": null
  },
  "HelpURL": null,
  "StackTraceString": "   at System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName)\r\n   at System.DirectoryServices.ActiveDirectory.Forest.GetForest(DirectoryContext context)\r\n   at System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOf(Principal p)\r\n   at System.DirectoryServices.AccountManagement.Principal.GetGroupsHelper()\r\n   at OGF.Home.Services.UserService.GetGroupsByLogin(String loginName) in C:\\Users\\alcide\\Sources\\OGF.Home\\OGF.Home.Services\\UserService.cs:line 162\r\n   at OGF.Home.Services.UserService.GetAdRoleByLogin(String loginName) in C:\\Users\\alcide\\Sources\\OGF.Home\\OGF.Home.Services\\UserService.cs:line 144\r\n   at OGF.Home.Services.UserService.GetAuthenticatedUser(String login) in C:\\Users\\alcide\\Sources\\OGF.Home\\OGF.Home.Services\\UserService.cs:line 127\r\n   at OGF.Home.WebApi.Controllers.AuthController.Authenticate() in C:\\Users\\alcide\\Sources\\OGF.Home\\OGF.Home.WebApi\\Controllers\\AuthController.cs:line 53\r\n   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()\r\n   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()\r\n   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()\r\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)\r\n   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)\r\n   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)\r\n   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\r\n   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)\r\n   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)\r\n   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)\r\n   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)\r\n   at OGF.Home.WebApi.Middleware.ExceptionMiddleware.InvokeAsync(HttpContext httpContext) in C:\\Users\\alcide\\Sources\\OGF.Home\\OGF.Home.WebApi\\Middleware\\ExceptionMiddleware.cs:line 27",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": null,
  "HResult": -2146233088,
  "Source": "System.DirectoryServices",
  "WatsonBuckets": null