Asp.net windows authentication 简单流程

API 程序的认证过程:

  1. 编写api程序
  2. 在startup.cs中的configureServices中添加services.AddAuthentication(IISDefaults.AuthenticationScheme)
  3. 在launchSettings.json中将 :"windowsAuthentication": true,    "anonymousAuthentication": true,
  4. 在controller中将函数的使用认证注解: [Authorize(Roles = @"care")] 其中的角色是在域环境中给您分配的组
  5. 配置域环境,在局域网中运行,要将自己服务器的DNS改成域环境的DNS
  6. 将自己在域环境中进行分组,对应4中的Roles
  7. 开启本地的IIS,在控制面板中:程序和功能中-》打开或关闭windows功能-》将INternet信息服务全选上,之后等待安装
  8. 之后将编写的工程发布到IIs的inetpub->wwwroot中,将发布的东西放在其中就好

注意:

  1. 在本地显示域环境相关信息和分组状况的命令:在cmd中输入:gpresult /V
  2.   window认证的获得其中用户的名字和相关的id的命令: System.Security.Principal.WindowsIdentity.GetCurrent()

猜你喜欢

转载自blog.csdn.net/u010565765/article/details/79543515