Azure active directory 使用C以编程方式创建Azure AD用户#

Azure active directory 使用C以编程方式创建Azure AD用户#,azure-active-directory,Azure Active Directory,我正在使用“Microsoft.Azure.ActiveDirectory.GraphClient.dll”和“Microsoft.IdentityModel.Clients.ActiveDirectory”作为参考库 在其中,有IUser对象,该对象包含“字符串邮件{get;set;}”属性。 所以,如果我创建IUser对象并分配电子邮件,则不会分配电子邮件,也不会创建用户。 在AZURE Active Directory中,用户配置文件具有电子邮件字段。 如果我用DisplayName和Us

我正在使用“Microsoft.Azure.ActiveDirectory.GraphClient.dll”和“Microsoft.IdentityModel.Clients.ActiveDirectory”作为参考库

在其中,有IUser对象,该对象包含“字符串邮件{get;set;}”属性。 所以,如果我创建IUser对象并分配电子邮件,则不会分配电子邮件,也不会创建用户。 在AZURE Active Directory中,用户配置文件具有电子邮件字段。 如果我用DisplayName和UserPrincipalName创建用户,那么就可以了 但对于DisplayName,UserPrincipalName和Mail user未创建

User  Create...

protected void btnAdd_Click(object sender, EventArgs e)
{
    ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClientAsApplication();

    IUser newUser = new User();
    newUser.DisplayName = "New User";
    newUser.UserPrincipalName = New.User123@deoshaligram.onmicrosoft.com

    //newUser.Mail = "newuser005@gmail.com";

    client.Users.AddUserAsync(newUser).Wait(10000);
}

User not Create and Email not assign...

protected void btnAdd_Click(object sender, EventArgs e)
{
    ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClientAsApplication();

    IUser newUser = new User();
    newUser.DisplayName = "New User";
    newUser.UserPrincipalName = New.User123@deoshaligram.onmicrosoft.com
    newUser.Mail = "newuser005@gmail.com";

    client.Users.AddUserAsync(newUser).Wait(10000);
}

您应该在上使用
othermail
属性,而不是
mail
属性


mail
属性是一个单值字段,由Exchange Online或Prem Directory Sync专门为用户的SMTP地址设置

您应该使用上的
othermail
属性,而不是
mail
属性

mail
属性是一个单值字段,由Exchange Online或Prem Directory Sync专门为用户的SMTP地址设置