Question

I am running IIS 7 on a server in the cloud. This server has a VPN connection back to our domain. The cloud server is not a member of the domain.

I need to create a folder on one of the domain servers, but I can't quite figure out how to impersonate a domain user. It appears that IIS is trying to validate the credentials on the cloud domain, not on our domain, so the impersonation fails.

I've tried mapping a network drive with the correct credentials and using this to create the folder, but it doesn't seem to work.

Can anyone point me in the right direction on how to accomplish this?

Was it helpful?

Solution

I found some code on http://blogs.msdn.com/b/joncole/archive/2009/09/21/impersonation-code-in-c.aspx which showed me how to impersonate a user.

The one tweak I had to make was to change

LogonType.Interactive,

to

LogonType.NewCredentials,

and it worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top