Property Error RRS feed

  • Question

  • User1901044945 posted

    Hi there, im having troubles getting the mail property when i make a search of users based on their first name, i think that on the search results there is a user that doesn't have an email address on the AD.

    What i want to ask you is how can I filter my search to make that the results brings me only the active users of the AD and how do i filter that search results so i can take out only the ones who has an email address asociated.

    Dim de As DirectoryEntry = New DirectoryEntry(adPath)

    Dim ds As DirectorySearcher = New DirectorySearcher(de)

    ds.Filter = "(&(&(objectClass=user)(objectCategory=person))((name=" & txt_nombre.Text & "*)))"



    Dim sr As SearchResult = Nothing

    Dim src As SearchResultCollection = ds.FindAll

    //This is the code im using that is blowing-up

    For Each sr In src

    If sr.Properties("mail")(0) Then                //This Filter is what i dont know how to make it work

    lbl_msg.Text = sr.Properties("mail")(0)  //Here is where the aplication stops on a user with out an email asociated.

    'Ckl_contactos2.Items.Add(New ListItem((sr.Properties("mail")(0))))

    End If

    Next sr

    thanks for your Help and sorry for me Typing and grammar.

    Saturday, August 12, 2006 2:39 PM

All replies

  • User1354132231 posted
    The common issues sticky post here on the forums would have answered this one for you (use the .Contains() check first).  However, if you want to filter them upfront add this to your filter: (mail=*)
    Monday, August 14, 2006 1:02 PM