首页 > 其他分享 >What's AD DS user?

What's AD DS user?

时间:2023-02-23 16:14:25浏览次数:63  
标签:What AD refresh access token user Azure

What's AD DS user?

AD DS stands for Active Directory Domain Services, which is a Microsoft technology that provides centralized authentication and authorization services for Windows-based computers. An AD DS user is a user account that is created and managed within an Active Directory Domain Services environment. AD DS users are used for authentication and authorization purposes, and can be used to control access to network resources such as files, folders, and printers. These users can be granted permissions to perform specific tasks and access specific resources on the network.

 

What does AcquireTokenSilent of IClientApplicationBase do?

AcquireTokenSilent() is a method in the IClientApplicationBase interface provided by the Microsoft.Identity.Client (MSAL) library in .NET. It is used to acquire a security token silently for an already authenticated user without prompting them for credentials again.

When a user first signs in, MSAL acquires an access token for them using an interactive flow that prompts the user to sign in and consent to requested permissions. However, subsequent requests for an access token can be made silently using the cached authentication information from the original sign-in. AcquireTokenSilent() will attempt to get an access token silently without interrupting the user, but will fall back to using an interactive flow if silent authentication fails.

In summary, AcquireTokenSilent() is used to acquire a token without prompting the user for credentials if the user has already signed in and consented to the requested permissions.

 

How about AcquireTokenInteractive?

AcquireTokenInteractive is another method in the IClientApplicationBase interface in Microsoft's authentication libraries that can be used to obtain an access token for a protected resource.

This method initiates an interactive authentication flow with the user, typically by opening a login prompt in a web browser. The user enters their credentials and, if authentication is successful, an access token is returned. This method is typically used when there is no cached token available or the cached token has expired.

The AcquireTokenInteractive method can be useful in scenarios where an application needs to obtain a token with a specific set of scopes or permissions, or when a user needs to grant consent to an application to access their data.

 

How can I remember the microsoft graph api already authenticcated?

When using Microsoft Graph API to authenticate and authorize users, you can use a refresh token to obtain new access tokens without requiring the user to sign in again. This allows you to remember that a user has already authenticated and authorized your application, and avoid unnecessary authentication prompts in the future.

To obtain a refresh token, you can request the offline_access scope when the user grants consent to your application. This scope allows your application to obtain refresh tokens and ensures that the user's access to your application doesn't expire.

To use the refresh token to obtain a new access token, you can call the AcquireTokenSilent method of the IClientApplicationBase interface. This method will attempt to acquire a new access token silently, using the refresh token if it is still valid and hasn't expired. If the refresh token has expired, the user will be prompted to sign in again.

Here's an example of using the AcquireTokenSilent method to obtain a new access token:

var app = PublicClientApplicationBuilder.Create(clientId)
    .WithAuthority(authority)
    .Build();

var accounts = await app.GetAccountsAsync();
var result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault())
    .ExecuteAsync();

In this example, clientId is the client ID of your application, authority is the authority URL of your Azure AD tenant, scopes are the permissions your application requires, and accounts is a list of accounts that have signed in to your application. The AcquireTokenSilent method will attempt to obtain a new access token for the first account in the accounts list. If the account has a valid refresh token, a new access token will be obtained silently.

 

When using Microsoft Graph API to authenticate and authorize users, you can use a refresh token to obtain new access tokens without requiring the user to sign in again. But How can I get the refresh token and when will refresh token expire?

To obtain a refresh token, you can use the OAuth 2.0 authorization code flow or implicit grant flow to acquire an initial access token and a refresh token from Azure AD. The refresh token is returned in the response to the initial token request, and it can be used to request new access tokens when the current access token expires.

The expiration time of a refresh token is determined by the policy configured in the Azure AD tenant. By default, refresh tokens issued for the Microsoft Graph API have a maximum lifetime of 90 days. After 90 days, the user will need to sign in again to obtain a new access token and refresh token.

Note that the refresh token can also be invalidated in certain circumstances, such as when the user changes their password or their account is disabled. In such cases, the user will need to sign in again to obtain a new access token and refresh token.

 

Give me an example about how to get a refresh token for a specific user

To get a refresh token for a specific user, you can use the OAuth 2.0 Authorization Code Grant flow. Here is an example of how to use this flow to get a refresh token for a user using the Microsoft Authentication Library (MSAL) for .NET in C#:

// Set up the confidential client application using MSAL
var confidentialClientApplication = ConfidentialClientApplicationBuilder
    .Create("your-client-id")
    .WithClientSecret("your-client-secret")
    .WithAuthority("https://login.microsoftonline.com/your-tenant-id")
    .Build();

// Set up the scopes for which to request access
var scopes = new[] { "user.read" };

// Redirect URI for the application (must match the one configured in the app registration)
var redirectUri = "http://localhost:8080";

// Generate the authorization request URL
var authorizationUrlBuilder = confidentialClientApplication
    .GetAuthorizationRequestUrl(scopes)
    .WithRedirectUri(redirectUri);

// Redirect the user to the authorization URL
// After the user completes the authentication flow, they will be redirected back to the specified redirect URI with an authorization code

// Get the authorization code from the redirect URI
var authorizationCode = "your-authorization-code";

// Use the authorization code to get a refresh token for the user
var authenticationResult = await confidentialClientApplication.AcquireTokenByAuthorizationCode(scopes, authorizationCode)
    .ExecuteAsync();
    
// The refresh token is available in the authentication result
var refreshToken = authenticationResult.RefreshToken;

Note that the user must first authenticate and authorize your application using the OAuth 2.0 Authorization Code Grant flow. After the user completes this flow, your application can exchange the authorization code for an access token and refresh token using the AcquireTokenByAuthorizationCode method of the confidential client application. The refresh token will be included in the authentication result returned by this method.

 

https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso

SSO via primary refresh token vs. Seamless SSO

For Windows 10, Windows Server 2016 and later versions, it’s recommended to use SSO via primary refresh token (PRT).

For Windows 7 and Windows 8.1, it’s recommended to use Seamless SSO. Seamless SSO needs the user's device to be domain-joined, but it isn't used on Windows 10 Azure AD joined devices or hybrid Azure AD joined devices. SSO on Azure AD joined, Hybrid Azure AD joined, and Azure AD registered devices works based on the Primary Refresh Token (PRT)

SSO via PRT works once devices are registered with Azure AD for hybrid Azure AD joined, Azure AD joined or personal registered devices via Add Work or School Account. For more information on how SSO works with Windows 10 using PRT, see: Primary Refresh Token (PRT) and Azure AD

 

Step 1. Determine your cloud identity model - Microsoft 365 Enterprise | Microsoft Learn

There are two types of managed authentication:

  • Password hash synchronization (PHS)

    Azure AD performs the authentication itself.

  • Pass-through authentication (PTA)

    Azure AD has AD DS perform the authentication.

 

Difference between Password hash synchronization (PHS) and Pass-through authentication (PTA)

Password Hash Synchronization (PHS) and Pass-through Authentication (PTA) are both authentication methods used in Azure Active Directory (Azure AD) for hybrid environments. Here are the differences between the two:

  1. Password Hash Synchronization (PHS): PHS is a method of synchronizing users’ hashed passwords from an on-premises Active Directory environment to Azure AD. When a user changes their password on-premises, the new hashed password is synchronized to Azure AD using a secure connection. When a user attempts to authenticate, the password hash is checked against the synchronized hash in Azure AD.

  2. Pass-through Authentication (PTA): PTA is a method of authenticating users’ on-premises passwords to Azure AD without synchronizing the password hash to the cloud. When a user attempts to authenticate, the password is validated against the on-premises Active Directory environment. If the password is correct, the authentication is passed through to Azure AD, allowing the user to access the requested resource.

In summary, PHS synchronizes password hashes from on-premises to the cloud, while PTA authenticates passwords on-premises and passes the authentication through to the cloud without synchronizing the password hash. Both methods are used for hybrid environments to provide seamless authentication for on-premises and cloud-based resources.

 

标签:What,AD,refresh,access,token,user,Azure
From: https://www.cnblogs.com/chucklu/p/17148389.html

相关文章

  • 2023-02-23 {"errMsg": "getImageInfo:fail download image fail. reason: downloadFi
    描述:微信小程序绘制图片业务,开发工具测试,真机测试,体验版测试均没问题,正式上线后报错:downloadFile:失败url不在域列表中报错原因:接口路径没有写在downloadFile合法域名里面......
  • shadow DOM
    https://developer.mozilla.org/zh-CN/docs/Web/Web_Components/Using_shadow_DOMWebcomponents的一个重要属性是封装——可以将标记结构、样式和行为隐藏起来,并与页面......
  • lazada商品详情数据接口采集代码展示
    业务背景 在很多行业,比如商品采集、刊登、直播、数据分析、竞价等行业都需要用到相关的销量接口,但是官方一般又没有开放这些接口,怎么办?解决方案(点击获取key和secret)目前......
  • Android----->多线程的实现Thread、IntentService的运用
       首先建立一个Intent.xml <?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"......
  • RTMP推送扩展支持HEVC(H265)之Metadata结构填写详解
    鉴于广大码友对上一篇文章​​RTMP推送扩展支持HEVC(H265)​​的Metadata数据结构还存在不清楚的地方,这里对RTMP推送Metadata的结构进行详解。首先,我们先讲解下H.264/AVC......
  • cannot load facet web
    菜单-->Preferences-->Plugins添加tomcat支持如图: 然后项目project-setting中可以添加web类型的facets了   pasting ......
  • kubeadm config images pull --image-repository 中国区镜像加速
    这是一个针对Kubernetes集群使用阿里云或其他中国区镜像加速器的命令。在中国大陆地区,由于网络限制,使用默认的DockerHub镜像仓库下载Kubernetes所需的Docker镜像可能会非......
  • Diffusers库的初识及使用
    diffusers库的目标是:将扩散模型(diffusionmodels)集中到一个单一且长期维护的项目中以公众可访问的方式复现高影响力的机器学习系统,如DALLE、Imagen等让开发人员可以很......
  • Mongodb-使用javaDriver 实现增删改查
    1.回顾  上篇已经学习了使用Mongodb_C#Driver实现增删改查2.重点这篇将学习怎样使用和学习Mongodb_javaDriver实现增删改查3.准备篇   在使用的时候请先准......
  • el-upload on-change/on-progress事件打包后不生效,本地运行正常的原因
      打包后会引入mockJs,查了网上的情况发现mockjs会使得element里面的组件表现异常,去掉就好了,再说了线上也用不到mockjs吧......