/// <summary> /// This method removes a member from a group /// </summary> /// <param name="user">The user to remove from the group</param> /// <param name="groupId">The ID of the target group</param> public static void RemoveMemberFromGroup(User user, String groupId) { MicrosoftGraphHelper.MakeDeleteRequest( String.Format("{0}groups/{1}/members/{2}/$ref", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, groupId, user.Id)); }
/// <summary> /// This method updated an existing user in Azure AD /// </summary> /// <param name="user">The user's fields to update</param> public static void UpdateUser(User user) { MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}users/{1}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, user.Id), user, "application/json"); }
/// <summary> /// This method adds a new member to a group /// </summary> /// <param name="user">The user to add as a new group's member</param> /// <param name="groupId">The ID of the target group</param> public static void AddMemberToGroup(User user, String groupId) { MicrosoftGraphHelper.MakePostRequest( String.Format("{0}groups/{1}/members/$ref", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, groupId), new GroupMemberToAdd { ObjectId = String.Format("{0}users/{1}/id", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, user.UserPrincipalName) }, "application/json"); }
/// <summary> /// This method adds a new user to Azure AD /// </summary> /// <param name="user">The user to add</param> /// <returns>The just added user</returns> public static User AddUser(User user) { String jsonResponse = MicrosoftGraphHelper.MakePostRequestForString( String.Format("{0}users", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri), user, "application/json"); var addedUser = JsonConvert.DeserializeObject<User>(jsonResponse); return (addedUser); }