473,703 Members | 2,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Director yServices.Searc hResultCollecti on results =
System.Director yServices.Searc hResultCollecti on();
Line 82: searcher.FindAl l();
Line 83: }
Source File: c:\inetpub\dev2 \adsearch\webfo rm1.aspx.cs Line: 81

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

System.Director yServices.Inter op.IDirectorySe arch.ExecuteSea rch(String
pszSearchFilter , String[] pAttributeNames , Int32 dwNumberAttribu tes,
IntPtr& hSearchResult) +0
System.Director yServices.Direc torySearcher.Fi ndAll(Boolean
findMoreThanOne )
System.Director yServices.Direc torySearcher.Fi ndAll()
adsearch.WebFor m1.btnSearch_Cl ick(Object sender, EventArgs e) in
c:\inetpub\dev2 \adsearch\webfo rm1.aspx.cs:81
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
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 3171
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__du nbar__AT__intec hnology__D0T__c o__D0Tuk> wrote
in message news:er******** *************** *********@4ax.c om...
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.Director yServices.Searc hResultCollecti on results =
System.Director yServices.Searc hResultCollecti on();
Line 82: searcher.FindAl l();
Line 83: }
Source File: c:\inetpub\dev2 \adsearch\webfo rm1.aspx.cs Line: 81

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

System.Director yServices.Inter op.IDirectorySe arch.ExecuteSea rch(String
pszSearchFilter , String[] pAttributeNames , Int32 dwNumberAttribu tes,
IntPtr& hSearchResult) +0
System.Director yServices.Direc torySearcher.Fi ndAll(Boolean
findMoreThanOne )
System.Director yServices.Direc torySearcher.Fi ndAll()
adsearch.WebFor m1.btnSearch_Cl ick(Object sender, EventArgs e) in
c:\inetpub\dev2 \adsearch\webfo rm1.aspx.cs:81
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
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
12178
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 with LDAP, without specifying a particular group? How can i retrieve a list of groups? thank you, -- i'm looking for any pointers.
1
1957
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 a 2003 server, it gets errors ranging from Item not found to "Unable to access directory services". The second I take the 2003 server offline, everything works fine again. I can't really give much code detail since i work on the network side...
1
2206
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 I did not know my domain name (which seems to be the same as my machine name) The program throws an exception on
1
1456
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 with System.DirectoryServices.DirectoryEntry I get an error when I make objUser.CommitChanges(). Can anybody tell me how to access and Change Active Directory Object with VB.NET? Thanks at All -- Arne Tiedemann www.bitbuilder.de
0
996
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 sn searches for surname) Thanks in advance!!
10
5823
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 I've found no solution. Can anyone help me with an example or with a link to solve my problem? Thanks a lot in advance!!!
4
5891
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
2217
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 is there any article which can explain it. kalaivanan
3
8174
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 stuff about retrieving data out of the AD (thanks to Tim Golden!), but how can I manipulate or change AD objects like users, computers and groups with Python? Is there somewhere a documentation or some code?
0
8750
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8662
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
9244
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
9111
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
8961
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...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4421
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2439
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2058
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.