Sumit Ghosh
Sumit Ghosh

Reputation: 3270

Ways of Authentication against a Windows Server in C# for a Client Application

I have windows server 2003 machine as a part of our network. I have created an administrator user on it.

Now this server system has a shared folder.

I am writing a C# application which will copy some files a local system to that shared folder in the windows server 2003 machine.

I have coded the file transfer code, it works fine if I authenticate the client machines using windows explorer to copy file into the shared folder on the server.

However If I don't authenticate using windows explorer my code gives Access Denied Error.

I want C# cope piece which can authenticate my file transfer application without entering the creds on windows explorer each time. The windows server has normal windows authentication.

Please help!!

Edit-

The server does not have an AD, please note that Iam authenticating against an AD, I just want to create an Authenticated windows session to the machine.

Upvotes: 0

Views: 2076

Answers (1)

Brannon
Brannon

Reputation: 26109

You need to use impersonation.

The following KB article has some good information on using impersonation from .NET: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158

A quick Google search turns up the following example (based on the same idea): http://www.codeproject.com/KB/cs/cpimpersonation1.aspx

Upvotes: 1

Related Questions