473,396 Members | 1,724 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,396 software developers and data experts.

Active Directory Objects - Object reference not set to an instance of an object.

Whilst creating a class to search Active Directory domains and
retrieve user details, I ran into the following error:-

Object reference not set to an instance of an object.

Here's the error log:

Source Error:
Line 79: StringBuilder summary
= new StringBuilder();
Line 80:
Line 81:
System.DirectoryServices.SearchResultCollection results =
System.DirectoryServices.SearchResultCollection();
Line 82: searcher.FindAll();
Line 83: }
Source File: c:\inetpub\dev2\adsearch\webform1.aspx.cs Line: 81

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]

System.DirectoryServices.Interop.IDirectorySearch. ExecuteSearch(String
pszSearchFilter, String[] pAttributeNames, Int32 dwNumberAttributes,
IntPtr& hSearchResult) +0
System.DirectoryServices.DirectorySearcher.FindAll (Boolean
findMoreThanOne)
System.DirectoryServices.DirectorySearcher.FindAll ()
adsearch.WebForm1.btnSearch_Click(Object sender, EventArgs e) in
c:\inetpub\dev2\adsearch\webform1.aspx.cs:81
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
I've tried several ways of doing this, and according to every
reference I have read (Including the C# book in front of me, which
uses EXACTLY the same method of returning the AD Search results)

If anyone could shed some light on why it's not behaving as expected,
I would be most greatful. Thanks.

- Jason
Nov 16 '05 #1
1 3160
Please post a larger part of the code, especially the part that initializes
the searcher reference as it happens to be null.

Willy.

"Jason Dunbar" <jason__D0T__dunbar__AT__intechnology__D0T__co__D0 Tuk> wrote
in message news:er********************************@4ax.com...
Whilst creating a class to search Active Directory domains and
retrieve user details, I ran into the following error:-

Object reference not set to an instance of an object.

Here's the error log:

Source Error:
Line 79: StringBuilder summary
= new StringBuilder();
Line 80:
Line 81:
System.DirectoryServices.SearchResultCollection results =
System.DirectoryServices.SearchResultCollection();
Line 82: searcher.FindAll();
Line 83: }
Source File: c:\inetpub\dev2\adsearch\webform1.aspx.cs Line: 81

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]

System.DirectoryServices.Interop.IDirectorySearch. ExecuteSearch(String
pszSearchFilter, String[] pAttributeNames, Int32 dwNumberAttributes,
IntPtr& hSearchResult) +0
System.DirectoryServices.DirectorySearcher.FindAll (Boolean
findMoreThanOne)
System.DirectoryServices.DirectorySearcher.FindAll ()
adsearch.WebForm1.btnSearch_Click(Object sender, EventArgs e) in
c:\inetpub\dev2\adsearch\webform1.aspx.cs:81
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
I've tried several ways of doing this, and according to every
reference I have read (Including the C# book in front of me, which
uses EXACTLY the same method of returning the AD Search results)

If anyone could shed some light on why it's not behaving as expected,
I would be most greatful. Thanks.

- Jason

Nov 16 '05 #2

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

Similar topics

4
by: CodeRazor | last post by:
I need to retrieve a list of groups from Active Directory. Then i need to retrieve a list of users from a group. I'm unfamiliar with Active Directory objects. Can i connect to Active Directory...
1
by: Michael | last post by:
Some of our developers are having a problem making certain code work that reads the contents of OUs in our Active Directory. It reads fine when querying a 2000 domain controller but when accessing...
1
by: Jack Russell | last post by:
I am trying to get the example in this help topic to work The only change that I have made is : entryPc.Path = "WinNT://" + Environment.UserDomainName + "/" + Environment.MachineName because...
1
by: Arne Tiedemann | last post by:
Hello NG, I'm new in programming VB.NET and I'll create a Project to read and change Active Directory Users, Groups, and Organisational Units. I test with VisualStudio 2003 but wenn i access Users...
0
by: Brian Mitchell | last post by:
Is there any way to return active directory objects from the object's guid? My basic problem is that I don't know the appropriate search filters. Does anyone know of any sites that list them? (like...
10
by: KarlM | last post by:
Hallo! System.Security.AccessControl.FileSecurity (GetAccessControl) works fine. Now I would like to use GetAccessControl for Active Directory Objects like computers. I've searched a lot but...
4
by: IainM | last post by:
How can I enumerate AD objects (only in a given OU, not sub OUs) using the DirectoryEntry object? Let me know of this is the wrong forum for this question. Thanks, Iain
6
by: kalaivanan | last post by:
hi, i am a beginner in c#. i have theoretical knowledge about object, reference and instance. but i want to know clearly about what is an object, reference and instance. can any one help me? or...
3
by: Dirk Hagemann | last post by:
Hi! Does anyone has experience with manipulating MS Active Directory objects? I'd like to delete some users from a group, but so far I couldn't find anything about this. There is some good...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.