C#: Access is denied when adding virtual FTP directory to IIS

V

Vincent Mouton

Hi,

I am trying to add an FTP Virtual Directory to IIS through C# code in an
ASP.NET page.
I'm getting an Access Denied Error when running the code below. I've left
out the code adding the directory itself.
For debugging purposes I tried to only execute the code below
(RefreshCache();), and even then I received that error.
From the beginning on, I've added the Username and Password property to the
DirectoryEntry instance.
See my code below.
note: target, username and password are parameters passed through a method
that holds this code.

DirectoryEntry folderRoot = new DirectoryEntry("IIS://" + target +
"/MSFTPSVC/1/Root");
folderRoot.Username = username;
folderRoot.Password = password;
folderRoot.RefreshCache();


Right before executing this, I managed to add a user account using this
instance of DirectoryEntry class.

DirectoryEntry AD = new DirectoryEntry("WinNT://" + target +
",computer",username,password);
(....)

And I managed to add a New Website in IIS (not a virtual directory) using an
WMI wrapper (ManagementClass, ManagementObject, etc...).
With the same UserName and Password as I tried to use to add the FTP virtual
directory.

thank you in advance,
Vincent
 
C

Cowboy \(Gregory A. Beamer\)

Spawn a thread with a user identity that has these rights. The other option
is giving the ASP.NET worker process and IUSR god-like rights (which means
any hacker is a god on your system).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
"Vincent Mouton"
 
V

Vincent Mouton

Hi,

sorry for my very late reply. I think the first solution is by far the bast
(no god messing with my security).

thanks for your insights!
Vincent
 

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