类型“ Microsoft.DirectoryServices.PasswordProfile”上不存在属性“ $ id”

时间:2020-03-30 23:17:01

标签: c# microsoft-graph-api microsoft-graph-sdks

我无法使用以下代码创建用户。我收到以下错误:

类型'Microsoft.DirectoryServices.PasswordProfile'上不存在属性'$ id'。确保仅使用由类型定义的属性名称。

Microsoft.Graph.PasswordProfile pf = new Microsoft.Graph.PasswordProfile
{
    ForceChangePasswordNextSignIn = true,
    Password = password
};

Microsoft.Graph.User newUser = new Microsoft.Graph.User
{
    Id = "",
    PasswordProfile = pf,
    Department = user.Department,
    DisplayName = user.DisplayName,
    GivenName = user.GivenName,
    JobTitle = user.JobTitle,
    AccountEnabled = true,
    MailNickname = user.MailNickname.Replace(" ", "").Replace(",", "").Replace("-", ""),
    MobilePhone = user.MobilePhone,
    OfficeLocation = user.OfficeLocation,
    PreferredLanguage = "en",
    Surname = user.Surname,
    Country = "US",
    UsageLocation = "US",
    OnPremisesImmutableId = user.OnPremisesImmutableId,
    UserPrincipalName = user.UserPrincipalName
};

int retrycount = 0;
retry:
    try
    {

        User createdUser = await graphClient.Users.Request().AddAsync(newUser);
        return createdUser.Id;
    }
    catch (Exception ex) { }

0 个答案:

没有答案