newUser.DisplayName = objUser.DisplayName;
newUser.UserPrincipalName = objUser.UserPrincipalName;
newUser.AccountEnabled = true;
newUser.MailNickname = "SampleAppDemoUser";
newUser.CompanyName = objUser.CompanyName;
newUser.PasswordProfile = new PasswordProfile
{
Password = objUser.PasswordProfile.Password,
ForceChangePasswordNextLogin = objUser.PasswordProfile.ForceChangePasswordNextLogin
};
newUser.Mobile = objUser.Mobile;
newUser.Department = objUser.Department;
newUser.JobTitle = objUser.JobTitle;
newUser.City = objUser.City;
newUser.UsageLocation = objUser.UsageLocation;
ActiveDirectoryClient clientUserCreate = AuthenticationHelper.GetActiveDirectoryClientAsApplication();
clientUserCreate.Users.AddUserAsync(newUser).Wait(10000);
var userid = newUser.ObjectId;
I am trying to create AAD user using above code. It is not throwing any error. Code runs smoothly. But it is not creating user in AD. When I am trying to get objectid of newly created user it gives null value.
If you have any idea then please suggest me. Is this issue related to Azure Configuration or permission or related to code ?
newUser
? If it's not defined, nothing will be added.newUser
variable too. Have you done this asIUser newUser = new User();
?