Error : Access is denied

Results 1 to 2 of 2

Thread: Error : Access is denied

  1. #1
    Join Date
    Dec 1969

    Default Error : Access is denied

    Hi All<BR> I have created an ASP.NET web application to create Virtual directory. When I run it in Browser and try to create virtual directory it gives "Access id denied" error. It seems there is some problem with permissions. Can anybody help me out and give some idea on what permission are required to create virtual directory dynamically through ASP.NET code.<BR><BR>Best Regards,<BR>Prasad<BR><BR> I have created following class in C# to create virtual directory.<BR><BR>using System;<BR>using System.DirectoryServices;<BR><BR>namespace IISADSI<BR>{<BR> /// &#060;summary&#062;<BR> /// Summary description for IISManager.<BR> /// &#060;/summary&#062;<BR> public class IISManager<BR> {<BR> /// &#060;summary&#062;<BR> /// Constructor<BR> /// &#060;/summary&#062;<BR> /// &#060;param name="serverName"&#062;Name of the IIS Server&#060;/param&#062;<BR> public IISManager(string serverName)<BR> {<BR> _serverName = serverName;<BR> }<BR> /// &#060;summary&#062;<BR> /// Default constructor uses localhost as default server<BR> /// &#060;/summary&#062;<BR> public IISManager()<BR> {<BR> _serverName = "localhost";<BR> }<BR> <BR> /// &#060;summary&#062;<BR> /// Connect to IISServer<BR> /// &#060;/summary&#062;<BR> public void Connect()<BR> {<BR> try<BR> {<BR> _iisServer = new DirectoryEntry("IIS://" + _serverName + "/W3SVC/1");<BR> }<BR> catch (Exception e)<BR> {<BR> throw new Exception("Could not connect to: " + _serverName,e);<BR> }<BR> }<BR><BR> /// &#060;summary&#062;<BR> /// Create a virtual directory<BR> /// &#060;/summary&#062;<BR> /// &#060;param name="nameDirectory"&#062;Name of the new virtual directory&#060;/param&#062;<BR> /// &#060;param name="realPath"&#062;Path of the directory&#060;/param&#062;<BR> public void CreateVirtualDirectory(string nameDirectory,string realPath)<BR> { <BR> DirectoryEntry folderRoot = _iisServer.Children.Find("Root",VirDirSchemaName); <BR> try<BR> {<BR> DirectoryEntry newVirDir = folderRoot.Children.Add(nameDirectory,VirDirSchema Name);<BR> // Set Properties<BR> newVirDir.Properties["AccessRead"].Add(true);<BR> newVirDir.Properties["Path"].Add(realPath);<BR> // Create a Application<BR> newVirDir.Invoke("AppCreate",true);<BR> // Save Changes<BR> newVirDir.CommitChanges();<BR> folderRoot.CommitChanges();<BR> _iisServer.CommitChanges();<BR> }<BR> catch (Exception e)<BR> {<BR> throw new Exception("Virtual Directory " + nameDirectory + " Already Exists",e);<BR> }<BR> }<BR> <BR> #region Properties<BR> public string ServerName<BR> {<BR> get<BR> {<BR> return _serverName;<BR> }<BR> set<BR> {<BR> _serverName = value;<BR> }<BR> }<BR> #endregion<BR> <BR> public static string VirDirSchemaName = "IIsWebVirtualDir";<BR> <BR> #region Private Members <BR> private string _serverName;<BR> private DirectoryEntry _iisServer;<BR> #endregion<BR> }<BR><BR><BR>}<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Error : Access is denied

    sounds to me like the page is being run ion anonymous context, and you require admin permisisons to create a new virt dir.<BR><BR>two choices. <BR><BR>1. force login with basic or windows authentication, then log in as a righted-up user<BR>2. configure IIS to run as a user with admin rights (les recommended)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts