4

Hopefully this explanation will make sense, but what is the best way (if it is even possible) to pass along user credentials to preform a specific application from an ASP.NET MVC application. Currently I am working on trying to create directories on another server, we can't do this using the generic credentials that the application is running with; however, we have been told that we can if we pass the credentials of the user currently using the application along.

Currently we are running on IIS 6.0 but will be moving to IIS 7.0 in the near future and likewise we are using Integrated Windows authentication for the web applications.

2 Answers 2

1

Here is a KB article which describes a few ways of doing user impersonation.

Note that some of their examples seem to be using the current authenticated user, but you can obviously adapt this to use whatever user you'd like.

Edit: I've used code very much like in the section "Impersonate a Specific User in Code" to access files on a remote share using the credentials of a user with access to said share. Pretty straight forward.

Sign up to request clarification or add additional context in comments.

5 Comments

Indeed, I just wrote some code into the system and it looks like we might have a winner. However, I am getting an error that "The specified network name is no longer available." when trying to create a directory. Any ideas?
@Frank - The path needs to be censored for obvious reasons but it's just a Directory.CreateDirectory("\\server\directory\new") call.
Hmm, are you able to do any other file operations? Read directory index, read the contents of an existing file, etc.
Odd, I just did a DirectoryInfo on the existing part of the path and I'm getting back that it doesn't exist from the code, but no issues actually connecting to it.
Looks like we are half way to the solution, I've opened up another question with the problems related to the credentials across the network. stackoverflow.com/questions/2632556
0

Yes. You should take a look at User property and the IIS Authenticated methods

1 Comment

That gives us the user who is currently accessing the site (we are using this for access control), but I'm looking for a way to pass this along to say, Directory.CreateDirectory so that user is preforming the action instead of the network service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.