问题描述
我需要使用C#来模拟用户。
我使用LogonUser Win32 API的。
从同一个域作为当前登录的用户冒充用户时,此工作正常。
但是我得到假作为回应,当我试图冒充其他域中的用户。
I need to impersonate a user using C#.I use the LogonUser Win32 API.This works fine when impersonating users from the same domain as the currently logged-in user.However I get "false" as response when I try to impersonate users from other domains.
这是什么原因?
推荐答案
您应该尝试调用GetLastError函数之后的LogonUser失败,看是否有错误信息中给出。
You should try calling GetLastError right after LogonUser fail to see if any error information is given.
有可能会出现一些问题,从C#调用GetLastError函数。
看这里它的更多信息:
There may be some issue with calling GetLastError from c#.
Look here for more information on this : http://blogs.msdn.com/adam_nathan/archive/2003/04/25/56643.aspx
是否有你的两个域之间的信任?如果没有,LogonUser的失败。
Is there a trust between your two domains? If not, LogonUser will fail.
这篇关于LogonUser的仅适用于我的域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!