首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏大内老A

    [WCF权限控制]从两个重要的概念谈起:Identity与Principal[下篇]

    只读属性Identity表示安全主体的身份,而IsInRole用以判断安全主体对应的用户是否被分配了给定的角色。 1: public interface IPrincipal 2: { 3: bool IsInRole(string role); 4: IIdentity Identity 和用户组名称,对于一些与定义的用户组甚至还可以通过System.Security.Principal.WindowsBuiltInRole枚举来表示,所以WindowsPrincipal具有若干重载的IsInRole (int rid); 5: public virtual bool IsInRole(SecurityIdentifier sid); 6: public virtual bool IsInRole(WindowsBuiltInRole role); 7: public virtual bool IsInRole(string role); 8: public

    1.3K90发布于 2018-01-16
  • 来自专栏菩提树下的杨过

    .net中的认证(authentication)与授权(authorization)

    HttpContext ctx = HttpContext.Current; if (ctx.User.Identity.IsAuthenticated && ctx.User.IsInRole bool isLogin = _principal.Identity.IsAuthenticated; bool isAdmin = _principal.IsInRole ("管理员"); bool isWebUser = _principal.IsInRole("网站会员"); Console.WriteLine("当前用户 ; if (User.IsInRole("管理员")) { Response.Write(" 当前用户角色 :管理员"); } if (User.IsInRole("会员")) {

    2.4K100发布于 2018-01-23
  • 来自专栏stcnb

    SYSLIB0002:PrincipalPermissionAttribute 已过时

    如果要将属性应用到 Web 应用上下文之外的库代码,请执行以下操作: 通过调用 IPrincipal.IsInRole(String) 方法,在方法开始时手动执行检查。 Thread.CurrentPrincipal.IsInRole("Administrators")) { throw new Exception("User is anonymous

    48730编辑于 2022-01-05
  • 来自专栏林德熙的博客

    dotnet 判断程序当前使用管理员运行降低权使用普通权限运行

    WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); if (principal.IsInRole WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); if (principal.IsInRole

    1.4K30发布于 2019-03-13
  • 来自专栏码客

    WPF开发之以管理员身份运行

    principal = new WindowsPrincipal(identity); //判断当前登录用户是否为管理员 if (principal.IsInRole WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current); return windowsPrincipal.IsInRole

    2.9K31发布于 2020-08-02
  • 来自专栏不做码农的开发者

    【asp.net core 系列】15 自定义Identity

    Identity { get; } bool IsInRole(string role); } IPrincipal提供了两个基础数据和方法,一个是获取一个Identity对象,一个是判断是否是某个角色 > PrimaryIdentitySelector { get; set; } 2.2 IsInRole 在Principal中,通常会存放一至多个Identity对象,每个 Identity对象有一至多个 与IsInRole的判断依据类似,这个属性会获取Identity中存放的Claim集合中第一个RoleType为ClaimType.Name的Claim,然后取值。

    1.1K20发布于 2020-07-13
  • 来自专栏Windows技术交流

    制作Windows自定义镜像实现新购机器自动设置静态DNS和hostname自动生效无需人为重启机器

    forc if(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole forc if(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole

    1.1K30编辑于 2023-10-13
  • 来自专栏Windows技术交流

    Windows UserData专题:修改光驱盘符

    forceif(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole

    2.2K30编辑于 2022-09-27
  • 来自专栏林德熙的博客

    WPF 设置管理员权限启动

    WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); if (principal.IsInRole

    2.6K20发布于 2020-02-17
  • 来自专栏晓晨的专栏

    .NET Core 操作 Windows 注册表

    WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); var isElevated = principal.IsInRole

    1.3K20发布于 2020-12-22
  • 来自专栏walterlv - 吕毅的博客

    在 Windows 系统上降低 UAC 权限运行程序(从管理员权限降权到普通用户权限)

    WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); 而如果要判断是否是管理员权限,则使用: 1 2 3 4 if (principal.IsInRole identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); if (principal.IsInRole

    3.5K40编辑于 2023-10-23
  • 来自专栏菩提树下的杨过

    关于Membership/Role您可能不知道的细节

    2.if (User.Identity.IsAuthenticated){...}或if (User.IsInRole("RoleName")){...}时,系统是从哪里知道当前用户是否已经登录(或是否属于某一角色

    752100发布于 2018-01-23
  • 来自专栏用户1175783的专栏

    启动管理员进程

    WindowsPrincipal principal = new WindowsPrincipal(identity); //判断当前用户是否为管理员 if (principal.IsInRole

    1.2K40发布于 2019-09-18
  • 来自专栏Windows技术交流

    Windows UserData专题:设置密码

    forceif(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole

    1.5K30编辑于 2022-09-27
  • 来自专栏Windows技术交流

    Windows UserData专题:设置静态DNS

    forceif(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole

    3.2K40编辑于 2022-09-27
  • 来自专栏大内老A

    从Trace和Debug来看条件编译(Conditional Compilation)

    Thread.CurrentPrincipal.IsInRole("Admin")) 5: { 6: throw new SecurityException("Access Thread.CurrentPrincipal.IsInRole("Admin")) 8: { 9: throw new SecurityException

    977110发布于 2018-02-08
  • 来自专栏圣杰的专栏

    Asp.net mvc 知多少(八)

    class CustomPrincipal : IPrincipal { public IIdentity Identity { get; private set; } public bool IsInRole CurrentUser.IsInRole(Roles)) { filterContext.Result = new RedirectToRouteResult(new

    1.9K90发布于 2018-01-11
  • 来自专栏大内老A

    [WCF权限控制]WCF的三种授权模式

    RoleProviderPrincipal(object roleProvider, ServiceSecurityContext securityContext); 4: public bool IsInRole

    1K70发布于 2018-01-16
  • 来自专栏Net分享

    NET任务调度框架Hangfire使用指南

    IsAuthenticated == true && authUser.IsInRole("YourRoleName"); // 替换 "YourRoleName

    1.7K10编辑于 2024-12-10
  • 来自专栏c#开发者

    企业库推广

    = null) { bool isInRole = principal.IsInRole("Manager"); } 5.5 Logging Application Block Create the

    2K130发布于 2018-04-13
领券