基于角色的认证 [英] Role based authendication

查看:145
本文介绍了基于角色的认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经使用文件夹身份验证开发了一个Web应用程序.但是现在我需要进行基于角色的身份验证,无论是否进行文件夹身份验证.例如我有两个管理员用户的应用程序.我需要定义两个管理员用户之间的角色差异.一个只能插入另一个,可以插入,删除和更新.

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.

推荐答案

首先,您从LDAP中获取登录的用户ID,如下所示:
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);
    }
}



在后端SQL中,您需要通过SQL Management Studio为LDAP用户ID配置SQL身份验证.



In the backend SQL, you need to configure SQL authentication through SQL Management Studio for the LDAP user ID.


这篇关于基于角色的认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆