C# – LogonUser works only for the domain

cimpersonationwinapi

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.

What can cause this?

Best Answer

As Joel says you need trust between the domains.

You also need to be carefull with respect to the security context of the process doing the delegation, and which domain the machine you are running on is in.

Both the machine and the user account of the process must be trusted for delegation, by the domain that you are trying to access.

This means that your code should be running on the domain that you are trying to access.

Hope this helps

Shiraz