Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have developed a web application using folder authentication. But now i need to give role based authentication with or without folder authentication. For example i have two admin user for the application. i need to define the role difference between two admin users. One can do insert only another one can do insert, delete and update.
Posted
Updated 12-Mar-12 2:19am
v2

1 solution

First, you fetch the logged IN user ID from LDAP as:
C#
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900