472,348 Members | 1,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

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 7192
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: hykim | last post by:
Hello, everyone. according to MSDN, there is any constructor of System.DirectoryServices.SearchResultCollection Class. if I implement...
0
by: Barbara Alderton | last post by:
I have a asp.net application that needs to access Active Directory information. I setup the retrieval using System.DirectoryServices to access...
2
by: Dave F. | last post by:
I just installed my ASP.NET app on a Win 2k server. I installed the files in a folder on D: and setup a virtual directory in IIS Default web. We...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very...
2
by: ad | last post by:
I have a virtual which is a web service. When I use the IP to get the web service, it return a access denied message:...
0
by: Telos | last post by:
I'm trying to write a windows service which reads some emails from Exchange Server through WebDAV, using C#.NET 2.0. Everything works fine when...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via...
2
by: =?Utf-8?B?RWRkaWU=?= | last post by:
Here is my scenario for a problem I can't solve. I am hosting a 3.5 WCF service in IIS on Windows Server 2003. The service works fine with the WCF...
2
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.