与PrincipalContext
在 WCF 服务背后的代码中。 WCF 服务正在模拟,以允许“直通”类型的身份验证。
虽然我用 Active Directory 做的其他事情(主要是System.DirectoryServices.Protocols
命名空间)在这种情况下工作正常,由于某种原因,System.DirectoryServices.AccountManagement 中的类会出现异常。失败的示例代码:
PrincipalContext context = new PrincipalContext(ContextType.Domain, domainName);
UserPrincipal user =
UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, UserName);
当我打电话给FindByIdentity
,我收到 COMException:“发生操作错误”。致电PrincipalContext
也失败,例如:
string server = context.ConnectedServer;
Both OperationContext.Current.ServiceSecurityContext
and Thread.CurrentPrincipal.Identity
显示模拟工作正常。而且,就像我说的,S.DS.P 中的其他 AD 任务运行良好。
如果我明确设置凭据PrincipalContext
,一切正常。例如:
PrincipalContext context =
new PrincipalContext(ContextType.Domain, domainName, user, password);
UserPrincipal user =
UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, UserName);
现在一切正常了。但我不会知道呼叫者的用户名和密码;我必须依靠模仿。
关于什么会导致我所看到的问题有什么想法吗?
提前致谢!
詹姆士