J
Jason Dunbar
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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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