我以前一直使用Active Directory身份验证库(ADAL)以编程方式添加用户,但是现在我需要定义“ signInNames”(=用户电子邮件),而ADAL似乎无法实现(请告诉我即时消息是否错误) 。
现在,我尝试按照MSDN上的文档以编程方式使用HTTP POST添加新用户(本地帐户)。
//Get access token (using ADAL)
var authenticationContext = new AuthenticationContext(AuthString, false);
var clientCred = new ClientCredential(ClientId, ClientSecret);
var authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, clientCred);
var token = authenticationResult.Result.AccessToken;
//HTTP POST CODE
const string mail = "new@email.com";
// Create a new user object.
var user = new CustomUser
{
accountEnabled = true,
country = "MS",
creationType = "LocalAccount",
displayName = mail,
passwordPolicies = "DisablePasswordExpiration,DisableStrongPassword",
passwordProfile = new passwordProfile { password = "jVPmEm)6Bh", forceChangePasswordNextLogin = true …Run Code Online (Sandbox Code Playgroud)