2016-05-11 4 views
0

Можно ли указать тип группы, когда она создана с помощью Microsoft.Azure.ActiveDirectory.GraphClient?Создать группу объявлений azure

Например, с кодом:

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», «»)

+0

Я ищу этот пост: http://stackoverflow.com/questions/37065503/how-can-i-create-group-mail-alias-using-office-365-api-in-c-sharp , Я нашел этот пост. Я попробую – user3668585

ответ

-1

Вы можете создать все типы групп, используя API диаграммы Microsoft, см. здесь документацию: https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/group_post_groups

+1

Ссылка хорошая, но вы не можете создавать все типы групп. Только унифицированный, динамичный и безопасный. –

0

Я создал эту группу!

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 
        } 
       } 
      } 
Смежные вопросы