我不确定这是否会进入系统管理员领域太远,但无论如何我都会问我的问题:)
我正在开发一个MVC3网站。该站点使用约束委派来模拟Windows域中的用户并连接到该用户下的SQL Server。这一切都没有问题。
我要做的是访问登录用户名的Display Name属性(使用以下代码):
string displayName;
var context = new PrincipalContext(ContextType.Domain, "contoso");
var userPrincipal = UserPrincipal.FindByIdentity(context,
IdentityType.SamAccountName,
userName);
displayName = userPrincipal.DisplayName;
我收到LDAP操作错误:
异常详细信息:System.Runtime.InteropServices.COMException:发生操作错误 System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context,IdentityType identityType,String identityValue)
奇怪的是:
答案 0 :(得分:0)
我通过将网站的PhysicalPathCredentials
设置为帐户来解决此问题。但我无法弄清楚问题的原因,但它确实有效。