How can i connect and login to Windows 2000 server from c# code?

G

Guest

Hi!
I have the following scenario:
I want to connect to a windows 2000 "File" -server from a ASP.Net -web
application, running under network service account and create a directory on
the file server. Both the web server and the file-server is in the same
Active Directory.
Clearly, the Network service account doesnt have the right permissions to
create a directory on the file server so i have to use another account that i
have.
My problem is that i dont know how to "logon" to the windows 2000 "file"
server from my c# asp.net -code to create the directory! Any ideas?
The IT-services people running our web servers dont allow web applications
to run under other accounts!

Ps. I'm really sorry if my post is in the wrong newsgroup, but i'm new here
and can't find my way around.. Ds.
 
B

BizWorld

Use NetworkCredential class to pass on the credentials that you want. OR
enable write permission on file server directory for ASP.net user and local
system account so that you can create directories under that above mentioned
directory.

Regards,

BizWorld
 
G

Guest

Thank you Bizworld for your answer,

The NetworkCredential class seems to be more directed at authenticating
towards web-based systems like web services, web sites etc.
If i choosed that way, i would have to have a web service on the "file"
-server that could take care of the directory creating business for me, and
thats not the kind of architecture i'm looking for. It would offcourse mean
installing IIS on file servers, running web services etc etc.

In the examples that i have found, for instance the WebRequest class that
uses NetworkCredential, there has always been a (object).Credentials
-property. The DirectoryInfo class, which i intended to use, doesn't have
that. After my somewhat limited reasearch, i've come to the conclusion that
this scenario is not supported by the .NET framework and that the only way is
to use Win32 and umC++.

I really hope that i am wrong, and that someone could point me in some
direction so i could solv this in .Net instead.

Regards, Mat
 
P

Peter Huang [MSFT]

Hi

Based on my understanding, you want to call the Directory.CreateDirectory
on a file server in a ASP.NET application which ran under the
network_service account.
e.g.
Directory.CreateDirectory(@"\\fileserver\test\createddir");

Since your two machine is in the same Domain, I think you may try to add
the domain\fileserver account into the Test folder share permission list,
so that
domain\fileserver will have the permission to create dir.

When ASP.NET app run under network_service account, it is using the machine
account, domain\fileserver to do the job.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top