udir
asked on
Difficult one...Active Directory + XML...
Hi,
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(
"LDAP://10.1.1.1/DC=Intern et,DC=Test ",
"User", "Password", AuthenticationTypes.Server Bind);
DirectorySearcher search = new DirectorySearcher(root);
search.Filter = "(&(objectClass=user))";
search.PropertiesToLoad.Ad d("ID");
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.Contain s("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 :
<names>
<way> SMS </way>
</names>
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?
Thanks
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(
"LDAP://10.1.1.1/DC=Intern
"User", "Password", AuthenticationTypes.Server
DirectorySearcher search = new DirectorySearcher(root);
search.Filter = "(&(objectClass=user))";
search.PropertiesToLoad.Ad
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.Contain
{
allUsers[counter] = ((string)result.Properties
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 :
<names>
<way> SMS </way>
</names>
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?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh, and i need to get the only the Name value - " EMail "
ASKER
or SMS
ASKER
OK, let me sumerize the problem so far:
1) If i write as you wrote : object deliveryValue = result.Properties["Deliver y"];
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 ["ladpcInf odelivery" ][0]);
i get nulls - " wayNode " is null (maybe somthing with the root)
How can it be solved (dosn't metter which way)
Thanks
1) If i write as you wrote : object deliveryValue = result.Properties["Deliver
i get an error : Data at the root level is invalid. Line 1, position 1
at the line : xml.LoadXml(deliveryValue.
(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
i get nulls - " wayNode " is null (maybe somthing with the root)
How can it be solved (dosn't metter which way)
Thanks
ASKER
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
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("//Ar
--------------------------
and the XML looks like this (when i get the property Value)
Value : <ArrayOfApp>
<App>
<Name>EVoucher</Name>
<Modules>
<Module>
<Name>UpdateDelivery</Name
<DeliveryMethods>
<DeliveryMethod>
<Name>HardCopy</Name>
</DeliveryMethod>
<DeliveryMethod>
<Name>Email</Name>
</DeliveryMethod>
</DeliveryMethods>
</Module>
</Modules>
</App>
</ArrayOfApp>
Am i missing somthing?