Reply to topic
system.directoryServices
byron
Forum Admin

Joined: 07 Mar 2004
Posts: 160
Location: Newark, DE, USA
Reply with quote
Trying to enumerate some web site setting via a web service on my local machine.

Here's the code:

[WebMethod]
public string getServiceNumber (string comment)
{
string rtn = "";
DirectoryEntry w3svc = new DirectoryEntry ("IIS://127.0.0.1/w3svc");
rtn = "";

try
{
foreach (string propName in w3svc.Properties.PropertyNames)
{
rtn = rtn + propName + " ";
}
}
catch (System.Exception e)
{
rtn = e.Message;
}
return rtn;
}

The errror I'm recieving is when propertyNames is accessed.

{"The directory cannot report the number of properties." }

Any help would be appreciated. Does this have something to do with my local machine Win Pro 2000, not having AD on it?
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
You need to use the DirectorySearcher class to do what you're trying to do if I'm not mistaken. This is off the top of my head, but try this.

Code:
Using System.DirectoryServices...

string serv = "IIS://127.0.0.1/w3svc";
w3svc = new DirectoryEntry(serv);
DirectorySearcher srch = new DirectorySearcher(w3svc);
SearchResultCollection results;
results = srch.FindAll();

foreach (SearchResult result in results)
{
   ResultPropertyCollection propColl = result.Properties;
}

foreach (string strKey in propColl.PropertyNames)
{
  foreach (object obProp in propColl[strKey])
  {
    this.AppendPropertyNode(obTopNode, strKey, obProp);
  }
}
byron
Forum Admin

Joined: 07 Mar 2004
Posts: 160
Location: Newark, DE, USA
Reply with quote
It did wind up being a syntax problem and the way I was accessing the objects. I'm still a little hazy on the permissions issues and what account the web services really run under.
system.directoryServices
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic