У меня есть небольшой код для удаления группы безопасности из Active Directory, но при запуске я получаю COMException с сообщением «Unspecified error».
Вот код:
public void DeleteGroup(Model.Asset pADSecurityGroup)
{
using(DirectoryEntry ou = new DirectoryEntry(pADSecurityGroup.Organization.ActiveDirectoryMappings.Single().Identifier))
using(DirectoryEntry group = new DirectoryEntry("LDAP://" + pADSecurityGroup.ActiveDirectoryMappings.Single().Identifier))
{
ou.Children.Remove(group);
group.CommitChanges();
}
}
А вот сообщение в консоли событий Windows:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 8/23/2011 11:29:35 AM
Event time (UTC): 8/23/2011 5:29:35 PM
Event ID: 67e6356c9ff146c7a0d9024350cbb3a0
Event sequence: 79
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT-2-129585938920392018
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\vo\Web\Portal\
Machine name: TR-2K8-001 Process information:
Process ID: 8348
Process name: w3wp.exe
Account name: VO\treed Exception information:
Exception type: COMException
Exception message: Unspecified error
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.Remove(DirectoryEntry entry)
at VirtualOffice.DirectoryServices.Impl.DirectoryService.DeleteGroup(ResourcePool pResourcePool) in C:\inetpub\wwwroot\vo\Common Libraries\VirtualOffice.DirectoryServices\Impl\DirectoryService.cs:line 249
at VirtualOffice.Controllers.ResourcePoolController.Delete(Int32 pServiceProviderId) in C:\inetpub\wwwroot\vo\Common Libraries\VirtualOffice.Controllers\ResourcePoolController.cs:line 171
at Organization_ResourcePools.rtbResourcePools_OnButtonClick(Object sender, RadToolBarEventArgs e) in c:\inetpub\wwwroot\vo\Web\Portal\Organization\ResourcePools.aspx.cs:line 85
at Telerik.Web.UI.RadToolBar.OnButtonClick(RadToolBarEventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: https://localhost:443/Organization/ResourcePools.aspx
Request path: /Organization/ResourcePools.aspx
User host address: ::1
User: Portal Admin
Is authenticated: True
Authentication Type: Federation
Thread account name: VO\treed Thread information:
Thread ID: 5
Thread account name: VO\treed
Is impersonating: False
Stack trace:
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.Remove(DirectoryEntry entry)
at VirtualOffice.DirectoryServices.Impl.DirectoryService.DeleteGroup(ResourcePool pResourcePool) in C:\inetpub\wwwroot\vo\Common Libraries\VirtualOffice.DirectoryServices\Impl\DirectoryService.cs:line 249
at VirtualOffice.Controllers.ResourcePoolController.Delete(Int32 pServiceProviderId) in C:\inetpub\wwwroot\vo\Common Libraries\VirtualOffice.Controllers\ResourcePoolController.cs:line 171
at Organization_ResourcePools.rtbResourcePools_OnButtonClick(Object sender, RadToolBarEventArgs e) in c:\inetpub\wwwroot\vo\Web\Portal\Organization\ResourcePools.aspx.cs:line 85
at Telerik.Web.UI.RadToolBar.OnButtonClick(RadToolBarEventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details: