Windows 7 DirectoryEntry.Bind Access Denied
I've been attempting to use DirectoryServices to get the AppPoolIdentityType for an IIS App Pool on Windows 7. I wrote a simple C# console app to retrieve the app pool Id for the DefaultAppPool. DirectoryEntry dirPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools/DefaultAppPool"); PropertyCollection props = dirPool.Properties; string strAppPoolIdType = props["AppPoolIdentityType"].Value.ToString(); Console.WriteLine("AppPoolIdentityType: " + strAppPoolIdType); I can run this on Win2008 Server and Vista, no problem. However, when I run this app on Windows 7, I get the following exception: Unhandled Exception: 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_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at GetAppPoolId.Program.Main(String[] args) I'm running this app from an admin account on both machines. Any ideas? Thanks, Wade
February 25th, 2010 2:41am

Hi Wade, Have you tried to disable the UAC? If not, you can try the following steps.1.Go to Start Menu -> Control Panel -> User Accounts -> User Account.2.Click on User Account Control settings-Choose Never Notify. I hope this can help you. John
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2010 12:03pm

UAC was the answer, I figured it out about 7PM last night. But I since I'm developing an app, I can't assume it's disabled. I figured out that I needed to setup the manifest to run the app as an admin automatically. UAC is one of the reasons Windows 7/Vista is user/developer hostile.
February 25th, 2010 7:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics