Good afternoon, I need a great help, I have a DAP access authentication, it is working correctly, validating username and password. However, I need a DAP field returned, this field is the "office", where we store information about the user's enrollment. It is critical that this field be (Office). Thank you in advance.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.DirectoryServices;
using System.Web;
namespace ActiveDirectory
{
public class AuthoAD
{
public string Autentica(string User, string Senha)
{
string retorno = string.Empty;
try
{
DirectoryEntry objAD = new DirectoryEntry("LDAP://master.meudominio.local:389", User, Senha);
HttpContext.Current.Session["login"] = objAD.Name;
retorno = objAD.Name;
}
catch (Exception ex)
{
HttpContext.Current.Session["login"] = "";
throw new Exception(ex.Message);
}
return retorno;
}
}
}