By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

web service system.directoryservices call access denied

P: n/a
I am using the following method in a web service that utilizes the
system.directoryservices namespace:
[WebMethod]
public ArrayList GetAllAppPools(){
System.DirectoryServices.DirectoryEntry apppools = new
DirectoryEntry("IIS://webserver/W3SVC/AppPools");
ArrayList appPoolNames = new ArrayList();
foreach(DirectoryEntry de in apppools.Children)
{
appPoolNames.Add(de.Name);
}
return appPoolNames;
}

However, when i try to test the web service method, i get the following
error in the browser:

System.Runtime.InteropServices.COMException (0x80070005): Access is denied
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsCont ainer()
at System.DirectoryServices.ChildEnumerator..ctor(Dir ectoryEntry
container)
at System.DirectoryServices.DirectoryEntries.GetEnume rator()
at WebService1.Service1.GetAllAppPools() in
c:\inetpub\wwwroot\webservice1\service1.asmx.cs:li ne 86

We think it has something to do with security and ADSI, but we're not sure
how to fix it. Does anyone have any ideas? The code/dll works perfectly in a
windows form application. We will happily answer any further questions about
the problem. Thanks.


Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jason,

You are right. By default, ASP.NET runs under the ASPNET local user
account, which has limited rights. Chances are your AD controller isn't set
up to allow access by that user (it doesn't have rights to the network
either).

To get around this, use the overload of the DirectoryEntry constructor
which takes a username and password as well, passing the username and
password of an account that has the appropriate rights to access the AD
controller.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason Gleason" <ja***********@gensurvey.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am using the following method in a web service that utilizes the
system.directoryservices namespace:
[WebMethod]
public ArrayList GetAllAppPools(){
System.DirectoryServices.DirectoryEntry apppools = new
DirectoryEntry("IIS://webserver/W3SVC/AppPools");
ArrayList appPoolNames = new ArrayList();
foreach(DirectoryEntry de in apppools.Children)
{
appPoolNames.Add(de.Name);
}
return appPoolNames;
}

However, when i try to test the web service method, i get the following
error in the browser:

System.Runtime.InteropServices.COMException (0x80070005): Access is denied
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsCont ainer()
at System.DirectoryServices.ChildEnumerator..ctor(Dir ectoryEntry
container)
at System.DirectoryServices.DirectoryEntries.GetEnume rator()
at WebService1.Service1.GetAllAppPools() in
c:\inetpub\wwwroot\webservice1\service1.asmx.cs:li ne 86

We think it has something to do with security and ADSI, but we're not sure
how to fix it. Does anyone have any ideas? The code/dll works perfectly in a windows form application. We will happily answer any further questions about the problem. Thanks.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.