如何阅读IPrincipal身份名称? [英] How to read IPrincipal identity name?

查看:68
本文介绍了如何阅读IPrincipal身份名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在写信寻求帮助,我如何获得以下行只读取身份名称。这是因为它当前抛出 - 角色管理器功能尚未启用错误。



Hi,

I am writing to seek help, in how do i get the following line to read only the identity names only. this is because it currently throws - "The Role Manager feature has not been enabled" error.

if (user.username != null)
            {
                // once the user is verified, assign it to an IPrincipal with the identity name and applicable roles
                principal = new GenericPrincipal(new GenericIdentity(user.username));
               
                return true;
            }





非常感谢您的时间和帮助。



Many thanks for your time and help.

推荐答案

如果您使用的是角色基础安全性,请检查您要使用的角色的角色基础设置。
If you are using role base security, then check role base settings for role which you want to use .


将以下行添加到您的web.config文件中。

Add following lines to your web.config file.
<roleManager defaultProvider="DefaultRoleProvider">
     <providers>
       <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
     </providers>
   </roleManager>


这篇关于如何阅读IPrincipal身份名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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