protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
try
{
string path = ConfigurationSettings.AppSettings["ldap"].ToString();
DirectoryEntry objEntry = new DirectoryEntry(path, txtUserName.Text.Trim(), txtPassword.Text.Trim());
DirectorySearcher search = new DirectorySearcher(objEntry);
search.Filter = "(&(objectCategory=person)(SAMAccountName=" + txtUserName.Text.Trim() + "))";
//search.Filter = "(&(objectCategory=person)(SAMAccountName=AjayK))";
SearchResult result = search.FindOne();
if (result != null)
{
DirectoryEntry de = result.GetDirectoryEntry();
PropertyValueCollection groups = de.Properties["memberOf"];
foreach (string s in groups)
{
//Response.Write(s + "<br/>");
if (s.Contains("Managers ABC"))
Session["isMgr"] = true;
}
Session["name"] = txtUserName.Text.Trim();
//Session["name"] = "rupeshm";
Response.Redirect("Index.aspx");
}
}
catch (DirectoryServicesCOMException)
{
{
lblMsg.Text = "Invalid User Name or Password!!";
}
}
}
{
try
{
string path = ConfigurationSettings.AppSettings["ldap"].ToString();
DirectoryEntry objEntry = new DirectoryEntry(path, txtUserName.Text.Trim(), txtPassword.Text.Trim());
DirectorySearcher search = new DirectorySearcher(objEntry);
search.Filter = "(&(objectCategory=person)(SAMAccountName=" + txtUserName.Text.Trim() + "))";
//search.Filter = "(&(objectCategory=person)(SAMAccountName=AjayK))";
SearchResult result = search.FindOne();
if (result != null)
{
DirectoryEntry de = result.GetDirectoryEntry();
PropertyValueCollection groups = de.Properties["memberOf"];
foreach (string s in groups)
{
//Response.Write(s + "<br/>");
if (s.Contains("Managers ABC"))
Session["isMgr"] = true;
}
Session["name"] = txtUserName.Text.Trim();
//Session["name"] = "rupeshm";
Response.Redirect("Index.aspx");
}
}
catch (DirectoryServicesCOMException)
{
{
lblMsg.Text = "Invalid User Name or Password!!";
}
}
}