First, you fetch the logged IN user ID from LDAP as:
WindowsIdentity ident = WindowsIdentity.GetCurrent();
WindowsPrincipal user = new WindowsPrincipal(ident);
string username = StripDomainFromUserName(user.Identity.Name);
using (DirectoryEntry de = new DirectoryEntry("LDAP://" + StripDomain(user.Identity.Name)))
{
using (DirectorySearcher adSearch = new DirectorySearcher(de))
{
adSearch.Filter = "(DomAccountName=" + username + ")";
SearchResult adSearchResult = adSearch.FindOne();
UserID = username;
UserName = StripLoggedUserName(adSearchResult.Path);
}
}
In the backend SQL, you need to configure SQL authentication through SQL Management Studio for the LDAP user ID.