Search code examples
c#securitywindows-server-2012iis-8.5

Access Denied error when I try to add a new virtual directory using a console application


I have upgraded to a new server and my console application tries to create a virtual directory in IIS 8.5 (Windows Server 2012).

I am getting this error:

[System.Runtime.InteropServices.COMException] {"Access is denied.\r\n"} System.Runtime.InteropServices.COMException ErrorCode 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.DirectoryEntries.CheckIsContainer() at System.DirectoryServices.DirectoryEntries.Find(String name, String schemaClassName)

I tried giving all permissions but still it is giving error as per this: Getting access denied while trying to create iis application from code


Solution

  • This Solution worked for me ==>

    http://blogs.msdn.com/b/jpsanders/archive/2009/05/13/iis-7-adsi-error-system-runtime-interopservices-comexception-0x80005000-unknown-error-0x80005000.aspx?CommentPosted=true#commentmessage ..

    I also have to do this to resolve Access denied error ==> Run all Administrator in admin approval mode ==> Disabled ..