473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problems with FindAll not finding any...

Hello,

I'm keping myself busy here by investigating the world of LDAP and Active
Directory. I have an application which allows users from the system to be
selected from a list box and as a result their mail address (as set in AD)
is returned. This is all fine untill I try to show the address of a user who
doesn't have one. In esscense, the DirectorySearcher.FindAll isn't finding
any.

Here's a copy of what I have:

'bind the directory entry to the root of the domain
Dim dEntry As New DirectoryEntry("LDAP://ABR-DC01")
Dim dSearch As New DirectorySearcher(dEntry)
'define the filter
dSearch.Filter = "(samAccountName=MyUserName)"
dSearch.SearchScope = SearchScope.Subtree
'define the properties to retrieve
dSearch.PropertiesToLoad.Add("mail")

'Define a collection to populate
Dim cResult As SearchResultCollection
'Excute the query
cResult = dSearch.FindAll

'query the collection and add each user name to the combo
Dim oRes As SearchResult
For Each oRes In cResult
If oRes.Properties("mail")(0) Then '<--- It errors here with no
address present
Get_Mail = "No address assigned"
Else
Get_Mail = oRes.Properties("mail")(0)
End If
Next

oRes = Nothing
cResult = Nothing
dSearch = Nothing
dEntry = Nothing

basicly, it errors when trying to do anything with oRes.Properties with an
error message of "Object reference not set to an instance of an object. "

Any idea of how i test if this collection is valid before trying to query
it? As you can see my code just isn't working.

Cheers,

<M>ike
Nov 21 '05 #1
1 1199
In the end i wrapped it in a Try - End Try statement (I think I should have
done this anyway) and set the Catch statement to display a 'No Address
Found' comment. It works, but it doesn't realy answer my question.

<M>ike
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gohaku | last post by:
Hi everyone, I am having a problem with the match function: import re string = 'abc 123456 xyz' if re.match("\d{1,}",string): print "Found a number" #Does not print whereas findall works:
3
by: Michael Rockwell | last post by:
I am new to using C# generics and I am liking what I am finding. However the examples in online help are lacking. Can someone help me with the FindAll method of the generic List class? As I...
5
by: Dave | last post by:
Hi All C# ADSI samples that I run cause unspecified errors. If I translate them into VB.NET they run fine. Here's an example: public string getEmail(string LDAPPath, string username) {...
5
by: Mystilleef | last post by:
Hello, Is there a simple flag to set to allow overlapping matches for the findall() regular expression method? In other words, if a string contains five occurrences of the string pattern "cat",...
7
by: Brian | last post by:
First off, I am sorry for cluttering this group with my inept questions, but I am stuck again despite a few hours of hair pulling. I have a function (below) that takes a list of html pages that...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
2
by: =?Utf-8?B?bWdvbnphbGVzMw==?= | last post by:
I have a List<tobject consisting of objects which in themselves consist of BindingListViews of objects. When I want to search for a object value I normally create a foreach loop and increment a...
0
by: Marco Hornung | last post by:
Hy guys, I'm using the python-framework BeautifulSoup(BS) to parse some information out of a german soccer-website. I spend some qualitiy time with the BS-docs, but I couldn't really figure out...
2
by: Alexnb | last post by:
Okay, I am not sure if there is a better way of doing this than findAll() but that is how I am doing it right now. I am making an app that screen scapes dictionary.com for definitions. However, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.