0

我们正在创建一个团队组(使用 beta Graph API),我们希望电子邮件地址包含另一个值,而不是基于displayName.

在搜索文档时,似乎可以通过为mailNicknamein AdditionalData( https://docs.microsoft.com/en-us/graph/teams-create-group-and-team ) 提供一个值来实现。

所以我实现了这一点。不幸的是,邮件地址和别名仍然像TestGroup@domain.nl而不是TestMailNickname@domain.nl.

var graphApiServiceClient = new GraphServiceClient(this.authenticationProvider)
{
    BaseUrl = "https://graph.microsoft.com/beta"
};

var owner = "valueForOwner";
var teamTemplate = teamTemplateType == TeamTemplateType.Staff
    ? "educationStaff"
    : "educationClass";

var team = new Team
{
    AdditionalData = new Dictionary<string, object>
    {
        { "template@odata.bind", $"https://graph.microsoft.com/beta/teamsTemplates('{teamTemplate}')" },
        { "owners@odata.bind", new[]{$"https://graph.microsoft.com/beta/users('{owner}')"}},
        { "displayName", "TestGroup" },
        { "description", "This is a testgroup" },
        { "mailNickname", "TestMailNickname" }
    }
};

await graphApiServiceClient.Teams.Request().AddAsync(team);

当我之后使用更新请求更新属性时,MailNickname 确实会发生变化。MailNicknameawait graphApiServiceClient.Groups[objectId].Request().UpdateAsync(new Group { MailNickname = mailNickname});

这得到了证实graphApiServiceClient.Groups[objectId].Request().GetAsync()

不幸的是,它仍然TestGroup@domain.nlhttps://admin.microsoft.com/AdminPortal/Home#/groups的管理员中显示为别名。

但是,像这样更新值不适用于Mail属性,因为它在更新请求中声明它是只读的。

有谁知道我在原始创建/添加请求中做错了什么?

另外有谁知道为什么仍然显示旧别名值而不是https://admin.microsoft.com/AdminPortal/Home#/groups上的更新别名?

4

2 回答 2

1

It looks like you are using an EDU tenant, since you are referencing the particular templates.

I have tested this previously, and the method suggested above will not work with the "EducationClass" template.

The way I got it to work was:

  • Create the Team with the template

        $Teamdata = 
            '{
                "displayName":"' + $newteamName + '",
                "description":"' + $newteamName + '",
                "template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates(\u0027educationClass\u0027)",
                "hideFromOutlookClients":  "true",
                "hideFromAddressLists":  "true",
                        "members":[
                    {
                        "@odata.type":"#microsoft.graph.aadUserConversationMember",
                        "roles":[
                        "owner"
                        ],
                        "user@odata.bind":"'+ $DefaultOwnerURL + '"
                    }
                ]
            }'

  • Wait for the group to be created (usually about 20 seconds)
  • patch the group mailnickname

        $Body_SetGroupSDSSettings = 
            '{
                "mailNickname": "' + $newteamMailNickname + '"
                
            }'

It isn't perfect, but it is the best way I could find to do this.

于 2021-09-08T01:29:36.890 回答
1

这可以通过首先通过 Graph api 创建一个组,然后使用组 ID 为该组创建一个团队来实现。

通过“https://graph.microsoft.com/v1.0/groups”创建组。

 {  
    "displayName": "TestGroup",  
    "mailNickname": "TestMailNickname",  
    "mailEnabled": true,  
    "securityEnabled": false,  
    "description": "This is a testgroup",  
    "groupTypes": [  
        "Unified"  
    ],  
    "owners@odata.bind": [  
        "https://graph.microsoft.com/v1.0/users/OWNEDID"  
    ]  
} 

组创建后,它将输出一个 ID,然后您将使用该 ID 通过“https://graph.microsoft.com/v1.0/groups/YOURIDHERE/team”创建团队

身体看起来像;

{  
    "memberSettings": {  
        "allowCreateUpdateChannels": false,
        "allowAddRemoveApps": false,
        "allowCreateUpdateRemoveTabs": false,
        "allowCreateUpdateRemoveConnectors": false  
    }
}
于 2020-12-03T11:13:34.870 回答