Hello; I am junior developer and pretty new to C# was wondering if someone could take look at my code and tell me why I get a "Object reference not set to an instance of an object" error message. my code is posted below... thanks in advance for any type of help.using System;
using System.DirectoryServices;
using System.Linq;
namespace AuctionDash
{
public partial class ActiveDirectory : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DirectoryEntry activeDirectory = new DirectoryEntry("LDAP://dc-1.domain.local",null,null)
activeDirectory.Path =
LDAP://dc-1.zachys.local/CN=aduc,CN=Users,DC=domian,DC=local;
DirectorySearcher adSearcher = new DirectorySearcher();
adSearcher.PropertiesToLoad.Add("name")
adSearcher.PropertiesToLoad.Add("Description");
adSearcher.Filter = (
"(&(&(objectClass=person)(objectcatagory=Group))(objectclass=Members))");
adSearcher.SearchScope = SearchScope=.Base:
SearchResultCollection results = adSearcher.FindAll();
if ((results != null) && (results.PropertiesLoaded.Contains("name" + "Description")))
results.PropertiesLoaded.ToString();
foreach (SearchResult result in results)
{
{
adSearcher.PropertiesToLoad.Add("name").ToString
adSearcher.PropertiesToLoad.Add("Description").ToString;
}
lblStatus.Text = adSearcher.SearchRoot.ToString();
adSearcher.Dispose();
}
}
}
}