无法为其他域用户创建WindowIdentity,例外 [英] Unable to create WindowIdentity for other Domain User, Exception
本文介绍了无法为其他域用户创建WindowIdentity,例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为其他域用户创建窗口标识对象,并将异常视为System.Security.SecurityException:登录失败:未知用户名或密码错误。该代码适用于同一域用户,请建议。在窗口中,我可以将文件共享给其他域用户。
I am trying to create window identity object for other domain user and getting exception as "System.Security.SecurityException: Logon failure: unknown user name or bad password." The code is working fine for same domain user, Please suggest. While in window i am able to share files to other domain user.
public WindowsIdentity ConvertUserNameIntoWindowsIdentity(string identityName)
{
try
{
return new WindowsIdentity(ind@asia.com);
}
catch (System.Security.SecurityException se)
{
}
}
推荐答案
这很简单。阅读WindowsIdentity类的文档:
It's simple really. Read the documentation on the WindowsIdentity class:
The caller does not have the correct permissions. (That would be YOU as any code you launch will run as you.)
-or-
The computer is not attached to a Windows 2003 or later domain.
-or-
The computer is not running Windows 2003 or later.
-or-
The user is not a member of the domain the computer is attached to.
此外,您发布的代码段甚至不会编译,因为ind@asia.com不在引号中。捕获异常并不做任何事情也不是一个好主意。
Also, the code snippet you posted won't even compile as the "ind@asia.com" is not in quotes. It's also not a good idea to catch the exception and do nothing it.
我在WCF服务中使用了Kerberos和NTLM身份验证来支持所有域用户。 NTLM身份验证用于崩溃案例,所以当kerberos auth。我没有使用NTLM身份验证进行模拟。对于Kerberose身份验证,我们将windowidentity创建为(new windowidentity(UserName @ domainname),对于NTLM身份验证,我们将窗口标识创建为(httpContext.Request.LogonUserIdentity)。
I used both Kerberos and NTLM authentication in my WCF Service to support all domain users. NTLM authentication is used in fall over case,So when kerberos auth. failed i do impersonation using NTLM authentication. For Kerberose authentication we create windowidentity as (new windowidentity(UserName@domainname)and For NTLM authentication we create window identity as(httpContext.Request.LogonUserIdentity).
这篇关于无法为其他域用户创建WindowIdentity,例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文