Help with array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry-OMAF

    #1

    Help with array

    I've created a method for a web service and it does exactly what I want it
    to do but one thing. Instead of just returning a concatenated "givenName"
    and "sn" I would like to be able to return an array that also has the users
    email address. How would I do that?

    [WebMethod]
    public ArrayList getAllADDomainU sers()
    {
    string [] strAttrs = new
    string[]{"givenName","s n","mail","SAMA ccountName","te lephoneNumber"} ;
    ArrayList allUsers = new ArrayList();

    DirectoryEntry searchRoot = new
    DirectoryEntry( "LDAP://ou=peeps,ou=Min e,dc=on,dc=ca") ;
    DirectorySearch er search = new DirectorySearch er(searchRoot);

    search.PageSize = 500;
    search.Filter = "(&(objectClass =user)(objectCa tegory=person)) ";
    search.Properti esToLoad.AddRan ge(strAttrs);
    search.Sort.Dir ection=SortDire ction.Ascending ;
    search.Sort.Pro pertyName="sn";

    SearchResult result;
    SearchResultCol lection resultCol = search.FindAll( );

    if (resultCol != null)
    {
    for(int counter=0; counter < resultCol.Count ; counter++)
    {
    result = resultCol[counter];
    if (result.Propert ies.Contains("g ivenName") &&
    result.Properti es.Contains("sn ") && result.Properti es.Contains("ma il"))
    {
    allUsers.Add(re sult.Properties["sn"][0].ToString() + ", " +
    result.Properti es["givenName"][0].ToString());
    //allUsers.Add(re sult.Properties["mail"][0].ToString());
    }
    }
    }
    return allUsers;
    }


Working...