[英]Create azure ad group
使用Microsoft.Azure.ActiveDirectory.GraphClient
创建组时,是否可以设置指定组的类型?
例如,代码:
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
};
但是我无法指定组类型(“统一”,“ DynamicMembership”,“”)
我创建了这个小组!
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.