我编写了一些代码来使用 C# 管理 AD LDS 容器的成员资格。DirectoryEntry
在我们的测试中,如果添加了某些人,则在尝试提交我们的更改时会引发错误。如果这些特定用户不包括在成员资格中,则代码可以正常工作。
生成的详细异常是:
System.DirectoryServices.DirectoryServicesCOMException 未处理
HResult=-2147016657
消息=发生约束冲突。Source=System.DirectoryServices
ErrorCode=-2147016657
ExtendedError=8373
ExtendedErrorMessage=000020B5:AtrErr:DSID-03152804,#1:
0:000020B5:DSID-03152804,问题1005(CONSTRAINT_ATT_TYPE),数据0,Att 1f(成员)StackTrace:
在 System.DirectoryServices.DirectoryEntry.CommitChanges()
at HCI.DirectoryServices.AdLds.Role.Save() 在 c:\Projects\ET\Shared\HCI.DirectoryServices\AdLds\Role.cs:HCI.Test
的第 186 行.ADManager.PasswordModifier.Main() 在 c:\Projects\ET\ADManager\HCI.Test.ADManager\Program.cs: 303 行,位于 Microsoft.VisualStudio
的 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,String[] args)
。 System.Threading.ExecutionContext.Run 的HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback 回调, 对象状态, Boolean preserveSyncCtx)
(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
从我在网上阅读的内容来看,此消息表明该组的成员属性存在问题,但我不知道它可能是什么。正如我所说,当排除这些特定用户时,相同的代码可以完美运行。我也找不到与问题用户的任何共性。
最后,如果我使用 ADSI Edit 手动将这些用户添加到容器中,那么我可以使用我的代码对他们做任何我想做的事情:删除、添加回、添加到不同的容器等。
建议表示赞赏。