Difficult one...Active Directory + XML...

I read from AD and The CN (commonName) has a property that if i get its value
i get it in XML format.
I'm lookin for some way to enter the nodes and retrieve the value.
My code (to get other properties valus) are:
DirectoryEntry root = new DirectoryEntry(
              "User", "Password", AuthenticationTypes.ServerBind);

            DirectorySearcher search = new DirectorySearcher(root);
            search.Filter = "(&(objectClass=user))";
            SearchResult result;
            SearchResultCollection resultCol = search.FindAll();
            string[] allUsers = new string[resultCol.Count];
            if (resultCol != null)
                     for (int counter = 0; counter < resultCol.Count; counter++)
                    result = resultCol[counter];
                    if (result.Properties.Contains("ID"))
                        allUsers[counter] = ((string)result.Properties["ID"][0]);                                      
                        Console.WriteLine("Value : " + allUsers[counter]);
and i get all the values of the ID propert.
Now, there is a property - which its value is in XML :
   <way> SMS </way>
The property name is : " Delivery ".
(if i try to retrieve Delivery value - i get an XML result.
I need to get only the value ---  SMS
Is it possible?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does it always return valid XML?  And does it return it as a string?
If so, something like:

    // ...
    object deliveryValue = result.Properties["Delivery"];
    string wayValue = null;
    if (deliveryValue != null)
        XmlDocument xml = new XmlDocument();
        XmlNode wayNode = xml.SelectSingleNode("//names/way");
        if (wayNode != null) wayValue = wayNode.Value;
    // ...



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
udirAuthor Commented:
Thanks for the reply.
It looks like the right way  (:
the problem is that i get nulls.
(i also changed the line to - object deliveryValue = ((string)result.Properties["ladpcInfodelivery"][0]);  )

Maybe the single Node Method has a wrong path?
the real pass that i wrote in the code in order to get to the Node is : (above i just gave an example)
XmlNode Nodename = xml.SelectSingleNode("//ArrayofApp/App/Name/Modules/Module/Name/DeliveryMethods/DeliveryMethod/Name");
and the XML looks like this (when i get the property Value)
Value : <ArrayOfApp>

Am i missing somthing?
udirAuthor Commented:
Oh, and i need to get the only the Name value - " EMail " 
udirAuthor Commented:
or SMS
udirAuthor Commented:
OK, let me sumerize the problem so far:
1)  If i write as you wrote :  object deliveryValue = result.Properties["Delivery"];
      i get an error :  Data at the root level is invalid. Line 1, position 1
      at the line :  xml.LoadXml(deliveryValue.ToString());
 (which i understand is becuase the property return not a valid XML but a string (as you can see in the file above - it really begins with " Value : <ArrayOfApp>...........

2)  If i write as I wrote :  object deliveryValue = ((string)result.Properties["ladpcInfodelivery"][0]);
      i get nulls - " wayNode " is null (maybe somthing with the root)

How can it be solved (dosn't metter which way)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.