我有一个 ASP.NET Web API 应用程序,它将包含 Active Directory 中的特定名称的所有组加载到内部数据库中。
这正在开发中。PC (Windows 10)、Testserver 和旧的 Productive Server (Windows Server 2012 R2) 但在新的 Productive Server (Windows 2016) 上,相同的方法遇到了异常。
尝试对已标记为删除的注册表项进行非法操作。
这里的代码:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal qbeGroup = new GroupPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);
var adGroups = srch.FindAll().Where(w => w.Name.Contains("_FS", StringComparison.InvariantCultureIgnoreCase));
var permissions = new List<PermissionGroup>();
// find all matches
foreach (var found in adGroups) {
var permission = new PermissionGroup(found.Name, found.Sid.ToString());
permissions.Add(permission);
}
附加信息: Windows Server 2016 Datacenter 版本 10.0.14393 Build 14393
安装 .NET Framework (Server 2016) .NET Framework 4.8 使用 .NET Framework 7
有人有一个想法,问题可能是什么?谢谢
添加:08.01.2020 16:11 (UTC +1)
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Runtime.InteropServices.COMException:尝试对已标记为删除的注册表项进行非法操作。
源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[COMException (0x800703fa): 试图对已标记为删除的注册表项进行非法操作。]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +535 System.DirectoryServices.DirectoryEntry.Bind() +48
System.DirectoryServices.DirectoryEntry.get_AdsObject() +43
System.DirectoryServices.PropertyValueCollection.PopulateList() +27
System.DirectoryServices .PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) +122
System.DirectoryServices.PropertyCollection.get_Item(String propertyName) +168
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +194 System.DirectoryServices.DirectoryEntry.Bind() + 48
System.DirectoryServices.DirectoryEntry.get_AdsObject() +43
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +91
System.DirectoryServices.DirectorySearcher.FindOne() +46
FragranceStudio.Webservice.Common.Helper.ActiveDirectoryHelper.SetADInformationToFragranceStudioPrincipal(FragranceStudioPrincipal香水StudioPrincipal) 在 C:\Repositories\VS2017\FragranceStudio\FragranceStudio \FragranceStudio.Webservice.Common\Helper\ActiveDirectoryHelper.cs:70 FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider.ReloadInheritedPermissionGroups(FragranceStudioPrincipal principal) 在 C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider .cs:142[FragranceStudioException:发生未知错误。请重试或联系服务台。]
FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider.ReloadInheritedPermissionGroups(FragranceStudioPrincipal principal) 在 C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider.cs:169 FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider。 C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider.cs:62 FragranceStudio.Webservice.Common.DomainEntities.Security.FragranceStudioPrincipal..ctor(IExtendedPermissionProvider extendedPermissionProvider, WindowsPrincipal 主体中的 GetInheritedGroups(FragranceStudioPrincipal 主体) ) 在 C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice 中。Common\DomainEntities\Security\FragranceStudioPrincipal.cs:55 FragranceStudio.Webservice.WebApiApplication.Application_PostAuthenticateRequest(Object sender, EventArgs e) 在 C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice\Global.asax.cs:51 系统中。 Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94Execute() +223 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94Execute() +223 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94