1

I have a .NET 3.5 application running with FullTrust permission. I want to use impersonation to read files on a network share. The application runs in the context of the logged in user and that user will not be an admin. My colleague says that in order to login to the server with different credentials local admin rights are required. Is this correct?

Useful links so far:

http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity

dior001
  • 751
  • 1
  • 13
  • 32

1 Answers1

2

I dont think so, Most of the shared drive ask for the authentication when you try to connect to them. I remember I took out my computer from the companies domain and then connected the shared drive by using another credential( not admin but had permission to access the drive) through a C# application. For that I used just PrincipalContext(ContextType.Domain) and credential UI pop up.

So the first check list for you is to ensure that your account has got access to the network share.

perilbrain
  • 7,961
  • 2
  • 27
  • 35
  • Thanks for your answer. I need to do this seamlessly without any login prompts appearing. – dior001 Aug 07 '12 at 18:25
  • 1
    See it depends on the configuration if you are logged in with some account that can access drive with windows authentication then the easiest way is to MAP the network drive on to local computer and make your application run without any extra headache. However for non window authentication I'll let you know other workaround later. – perilbrain Aug 07 '12 at 18:37
  • 1
    @ernie99:- Please look here for a solution http://stackoverflow.com/questions/1432213/copy-file-on-a-network-shared-drive – perilbrain Aug 07 '12 at 18:40
  • Thanks for that. Do you know if the example http://stackoverflow.com/questions/1432213/copy-file-on-a-network-shared-drive works if the context of the code that calls identity impersonate doesn't have admin rights? – dior001 Aug 07 '12 at 19:32
  • 1
    @ernie99 Its not necessary that you should have admin right but its quite necessary that your identity should have access to that drive. – perilbrain Aug 07 '12 at 19:36