469,593 Members | 1,877 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,593 developers. It's quick & easy.

web service system.directoryservices call access denied

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
1 6895
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.

Similar topics

reply views Thread by Barbara Alderton | last post: by
3 posts views Thread by Shailesh Humbad | last post: by
2 posts views Thread by ad | last post: by
reply views Thread by Telos | last post: by
2 posts views Thread by =?Utf-8?B?RWRkaWU=?= | last post: by
2 posts views Thread by =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.