Is it possible to set specify the type of group when it is created with Microsoft.Azure.ActiveDirectory.GraphClient
?
For example with the code:
Group groupToBeAdded = new Group
{
DisplayName = "group name",
Description = string.Empty,
MailNickname = member.Name,
MailEnabled = true,
SecurityEnabled = true, // Set to true for security-enabled groups. Set to false if creating an Office 365 group
Mail = AppConstants.EmailProperty
};
But I can't specify the group type ("Unified", "DynamicMembership", "")
I created this group!
AuthenticationContext authenticationContext = new AuthenticationContext("https://login.windows.net/" + Constants.TenantName, false);
var clientCredential = new ClientCredential(Constants.ClientId, Constants.ClientSecret);
AuthenticationResult authenticationResult = authenticationContext.AcquireToken("https://graph.microsoft.com/", clientCredential);
string token = authenticationResult.AccessToken;
string content = @"{
""displayName"": ""mailgrouptest"",
""groupTypes"": [""Unified""],
""mailEnabled"": true,
""mailNickname"": ""mailalias"",
""securityEnabled"": false
}";
using (var client = new HttpClient())
{
string uri = "https://graph.microsoft.com/v1.0/groups";
using (var request = new HttpRequestMessage(HttpMethod.Post, uri))
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
string json = content;
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
using (HttpResponseMessage response = client.SendAsync(request).Result)
{
//response.IsSuccessStatusCode
}
}
}
您可以使用Microsoft Graph API创建所有类型的组,请参阅此处的文档: https : //graph.microsoft.io/en-us/docs/api-reference/v1.0/api/group_post_groups
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.