EDN Admin
Well-known member
Dear Exprt,
One more time i am initialting this topic for your usual support please assist...
public DataTable ADEmpid(string Num)
{
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + GetSystemDomain());
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = "(&((&(objectCategory=Person)(objectClass=User)))(extensionAttribute2=" + Num + "))";
DataTable dt = new DataTable();
dt.Columns.Add("LogonName");
dt.Columns.Add("Name");
dt.Columns.Add("Employee ID");
dt.Columns.Add("Company");
SearchResult sResultSet = Dsearch.FindOne();
{
DataRow dr = dt.NewRow();
dr[0] = (GetProperty(sResultSet, "samaccountname"));
dr[1] = (GetProperty(sResultSet, "name"));
dr[2] = (GetProperty(sResultSet, "ExtensionAttribute2"));
dr[3] = (GetProperty(sResultSet, "Company"));
dt.Rows.Add(dr);
}
return dt;
}
catch (Exception ex)
{
return null;
}
}
//==========================
// On Button
//==========================
private void button2_Click(object sender, EventArgs e)
{
StreamReader myReader = new StreamReader("EmpIDs.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
{
dataGridView1.DataSource = ADEmpid("line");
}
}
myReader.Close();
}
receive error : - {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
Support@Mytechnet.me
View the full article
One more time i am initialting this topic for your usual support please assist...
public DataTable ADEmpid(string Num)
{
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + GetSystemDomain());
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = "(&((&(objectCategory=Person)(objectClass=User)))(extensionAttribute2=" + Num + "))";
DataTable dt = new DataTable();
dt.Columns.Add("LogonName");
dt.Columns.Add("Name");
dt.Columns.Add("Employee ID");
dt.Columns.Add("Company");
SearchResult sResultSet = Dsearch.FindOne();
{
DataRow dr = dt.NewRow();
dr[0] = (GetProperty(sResultSet, "samaccountname"));
dr[1] = (GetProperty(sResultSet, "name"));
dr[2] = (GetProperty(sResultSet, "ExtensionAttribute2"));
dr[3] = (GetProperty(sResultSet, "Company"));
dt.Rows.Add(dr);
}
return dt;
}
catch (Exception ex)
{
return null;
}
}
//==========================
// On Button
//==========================
private void button2_Click(object sender, EventArgs e)
{
StreamReader myReader = new StreamReader("EmpIDs.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
{
dataGridView1.DataSource = ADEmpid("line");
}
}
myReader.Close();
}
receive error : - {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
Support@Mytechnet.me
View the full article