473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 DirectorySearch er.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 DirectorySearch er(dEntry)
'define the filter
dSearch.Filter = "(samAccountNam e=MyUserName)"
dSearch.SearchS cope = SearchScope.Sub tree
'define the properties to retrieve
dSearch.Propert iesToLoad.Add(" mail")

'Define a collection to populate
Dim cResult As SearchResultCol lection
'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 1230
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
3370
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
31448
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 understand the method, it will return a list that meets the criteria evaluated in the delegate function that I use for evaluation. I am not sure how to write this delegate, how do I get the list item to evaluate in my delegate. Is their a defined...
5
24746
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) { DirectoryEntry entry = new DirectoryEntry(LDAPPath);
5
8498
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", calling findall on the string returns a list containing five "cat" strings. Is it possible for findall() to just return one "cat" string? Thanks
7
3119
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 have images on them (not porn but boats). This function then (supposedly) goes through and extracts the links to those images and puts them into a list, appending with each iteration of the for loop. The list of html pages is 82 items long and...
5
3842
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 connectivity for basic operations and such. I've ran into a snag that I just can't think myself out of. Here's an example: I have an object for a Student called StudentRecord. It has properties such as name, grade, identification number, etc.
2
2262
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 counter to provide me a count. How can I refactor the same function w/o the foreach and use findall instead? faux data structure: --------------------- -> | Customers
0
1078
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 how to get what I was looking for. Here's the deal: I want to parse the article shown on the website. To do so I want to use the Tag " <div class="txt_fliesstext">" as a starting-point. When
2
6369
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 would like to have the type of the word for each definition. For example if def1 and def2 are noun defintions but def3 isn't: noun def1 def2
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.