S
Stephane
Hi,
I want to create a virtual directory when a user has filled a form on an
ASP.net page. It works well on my dev server, but when I try it on my
production server, it fails. I got this error:
System.Runtime.InteropServices.COMException (0x80070005): Access is denied
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.ChildEnumerator..ctor(DirectoryEntry container)
at System.DirectoryServices.DirectoryEntries.GetEnumerator()
This is my code:
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
int siteId = 1;
IEnumerator list = root.Children.GetEnumerator();
while (list.MoveNext() && !isFound)
{
DirectoryEntry e = (DirectoryEntry)list.Current;
if(e.SchemaClassName == "IIsWebServer")
{
string desc = (string)e.Invoke("Get","ServerComment");
if(desc == LIVESNAP_NAME)
{
siteId = Convert.ToInt32(e.Name);
isFound = true;
}
}
}
I tried setting full control to everyone: It failed.
I tries impersonation with an admin account: it works
I tries impersonation with a power user acount: it works sometimes...
How can have this to work without using an admin account? I think this is
not really secure to use an admin username an password in the web.config
file...
Any idea?
Thanks
Stephane
I want to create a virtual directory when a user has filled a form on an
ASP.net page. It works well on my dev server, but when I try it on my
production server, it fails. I got this error:
System.Runtime.InteropServices.COMException (0x80070005): Access is denied
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.ChildEnumerator..ctor(DirectoryEntry container)
at System.DirectoryServices.DirectoryEntries.GetEnumerator()
This is my code:
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
int siteId = 1;
IEnumerator list = root.Children.GetEnumerator();
while (list.MoveNext() && !isFound)
{
DirectoryEntry e = (DirectoryEntry)list.Current;
if(e.SchemaClassName == "IIsWebServer")
{
string desc = (string)e.Invoke("Get","ServerComment");
if(desc == LIVESNAP_NAME)
{
siteId = Convert.ToInt32(e.Name);
isFound = true;
}
}
}
I tried setting full control to everyone: It failed.
I tries impersonation with an admin account: it works
I tries impersonation with a power user acount: it works sometimes...
How can have this to work without using an admin account? I think this is
not really secure to use an admin username an password in the web.config
file...
Any idea?
Thanks
Stephane