Search Results for

    Show / Hide Table of Contents

    Class GroupsUtility

    Class that deals with Azure Active Directory group CRUD operations.

    Inheritance
    System.Object
    GroupsUtility
    Namespace: PnP.Framework.Graph
    Assembly: PnP.Framework.dll
    Syntax
    public static class GroupsUtility : object

    Methods

    AddGroupMembers(String, String[], String, Boolean, Int32, Int32, AzureEnvironment)

    Adds members to an Azure Active Directory group

    Declaration
    public static void AddGroupMembers(string groupId, string[] members, string accessToken, bool removeExistingMembers = false, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    Id of the Azure Active Directory group to add the members to

    System.String[] members

    String array with the UPNs of the users that need to be added as members to the group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Boolean removeExistingMembers

    If true, all existing members will be removed and only those provided will become members. If false, existing members will remain and the ones provided will be added to the list with existing members.

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    AddGroupOwners(String, String[], String, Boolean, Int32, Int32, AzureEnvironment)

    Adds owners to an Azure Active Directory group

    Declaration
    public static void AddGroupOwners(string groupId, string[] owners, string accessToken, bool removeExistingOwners = false, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    Id of the Azure Active Directory Group to add the owners to

    System.String[] owners

    String array with the UPNs of the users that need to be added as owners to the group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Boolean removeExistingOwners

    If true, all existing owners will be removed and only those provided will become owners. If false, existing owners will remain and the ones provided will be added to the list with existing owners.

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    ClearGroupMembers(String, String, Int32, Int32)

    Removes all members of an Azure Active Directory group

    Declaration
    public static void ClearGroupMembers(string groupId, string accessToken, int retryCount = 10, int delay = 500)
    Parameters
    System.String groupId

    Id of the Azure Active Directory group to remove all the current members of

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    ClearGroupOwners(String, String, Int32, Int32)

    Removes all owners of an Azure Active Directory group

    Declaration
    public static void ClearGroupOwners(string groupId, string accessToken, int retryCount = 10, int delay = 500)
    Parameters
    System.String groupId

    Id of the Azure Active Directory group to remove all the current owners of

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    CreateGroup(String, String, String, Boolean, Boolean, String, String[], String[], Int32, Int32, AzureEnvironment)

    Creates a new Azure Active Directory Group

    Declaration
    public static GroupEntity CreateGroup(string displayName, string description, string mailNickname, bool mailEnabled, bool securityEnabled, string accessToken, string[] owners = null, string[] members = null, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String displayName

    The Display Name for the Azure Active Directory Group

    System.String description

    The Description for the Azure Active Directory Group

    System.String mailNickname

    The Mail Nickname for the Azure Active Directory Group

    System.Boolean mailEnabled

    Boolean indicating if the group will be mail enabled

    System.Boolean securityEnabled

    Boolean indicating if the group will be security enabled

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.String[] owners

    A list of UPNs for group owners, if any

    System.String[] members

    A list of UPNs for group members, if any

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    GroupEntity

    The just created Azure Active Directory Group

    DeleteGroup(String, String, Int32, Int32, AzureEnvironment)

    Deletes an Azure Active Directory Group

    Declaration
    public static void DeleteGroup(string groupId, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    The ID of the Azure Active Directory Group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    GetDeletedGroup(String, String, Uri)

    Gets one deleted Azure Active Directory group based on its ID

    Declaration
    public static GroupEntity GetDeletedGroup(string groupId, string accessToken, Uri graphBaseUri = null)
    Parameters
    System.String groupId

    The ID of the deleted group.

    System.String accessToken

    Access token for accessing Microsoft Graph

    Uri graphBaseUri

    The Microsoft Graph URI to use

    Returns
    GroupEntity

    The unified group object of the deleted group that matches the provided ID.

    GetGroup(String, String, Int32, Int32, AzureEnvironment)

    Get an Azure Active Directory Group by Id

    Declaration
    public static GroupEntity GetGroup(string groupId, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    The ID of the Azure Active Directory Group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    GroupEntity

    Group instance if found

    GetGroupMembers(GroupEntity, String, Int32, Int32, AzureEnvironment)

    Returns all the Members of an Azure Active Directory group

    Declaration
    public static List<GroupUser> GetGroupMembers(GroupEntity group, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    GroupEntity group

    The Azure Active Directory group to return its members of

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    List<GroupUser>

    Members of an Azure Active Directory group

    GetGroupOwners(GroupEntity, String, Int32, Int32, AzureEnvironment)

    Returns all the Owners of an Azure Active Directory group

    Declaration
    public static List<GroupUser> GetGroupOwners(GroupEntity group, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    GroupEntity group

    The Azure Active Directory group object

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    List<GroupUser>

    Owners of an Azure Active Directory group

    GetGroups(String, String, String, Int32, Nullable<Int32>, Int32, Int32, Int32, AzureEnvironment)

    Returns all the Azure Active Directory Groups in the current Tenant based on a startIndex.

    Declaration
    public static List<GroupEntity> GetGroups(string accessToken, string displayName = null, string mailNickname = null, int startIndex = 0, int? endIndex = null, int retryCount = 10, int delay = 500, int pageSize = 999, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.String displayName

    The DisplayName of the Azure Active Directory Group. Leave NULL if you do not want to filter by display name.

    System.String mailNickname

    The MailNickname of the Azure Active Directory Group. Leave NULL if you do not want to filter by mail nickname.

    System.Int32 startIndex

    If not specified, method will start with the first group.

    System.Nullable<System.Int32> endIndex

    If not specified, method will return all groups.

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    System.Int32 pageSize

    Page size used for the individual requests to Micrsoft Graph. Defaults to 999 which is currently the maximum value.

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    List<GroupEntity>

    List of GroupEntity objects

    ListDeletedGroups(String, Uri)

    Lists deleted Azure Active Directory groups

    Declaration
    public static List<GroupEntity> ListDeletedGroups(string accessToken, Uri graphBaseUri = null)
    Parameters
    System.String accessToken

    Access token for accessing Microsoft Graph

    Uri graphBaseUri

    The Microsoft Graph URI to use

    Returns
    List<GroupEntity>

    A list of Azure Active Directory group objects that have been deleted

    PermanentlyDeleteGroup(String, String, Uri)

    Permanently deletes one deleted Azure Active Directory group based on its ID

    Declaration
    public static void PermanentlyDeleteGroup(string groupId, string accessToken, Uri graphBaseUri = null)
    Parameters
    System.String groupId

    The ID of the group to permanently delete

    System.String accessToken

    Access token for accessing Microsoft Graph

    Uri graphBaseUri

    The Microsoft Graph URI to use

    RemoveGroupMembers(String, String[], String, Int32, Int32, AzureEnvironment)

    Removes members from an Azure Active Directory group

    Declaration
    public static void RemoveGroupMembers(string groupId, string[] members, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    Id of the Azure Active Directory group to remove the members from

    System.String[] members

    String array with the UPNs of the users that need to be removed as members from the group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    RemoveGroupOwners(String, String[], String, Int32, Int32, AzureEnvironment)

    Removes owners from an Azure Active Directory group

    Declaration
    public static void RemoveGroupOwners(string groupId, string[] owners, string accessToken, int retryCount = 10, int delay = 500, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    Id of the Azure Active Directory group to remove the owners from

    System.String[] owners

    String array with the UPNs of the users that need to be removed as owners from the group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    RestoreDeletedGroup(String, String, Uri)

    Restores one deleted Azure Active Directory group based on its ID

    Declaration
    public static void RestoreDeletedGroup(string groupId, string accessToken, Uri graphBaseUri = null)
    Parameters
    System.String groupId

    The ID of the deleted group

    System.String accessToken

    Access token for accessing Microsoft Graph

    Uri graphBaseUri

    The Microsoft Graph URI to use

    SetGroupVisibility(String, String, Nullable<Boolean>, Nullable<Boolean>, AzureEnvironment)

    Sets the visibility of an Azure Active Directory Group

    Declaration
    public static void SetGroupVisibility(string groupId, string accessToken, bool? hideFromAddressLists, bool? hideFromOutlookClients, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    Id of the Azure Active Directory Group to set the visibility state for

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Nullable<System.Boolean> hideFromAddressLists

    True if the group should not be displayed in certain parts of the Outlook UI: the Address Book, address lists for selecting message recipients, and the Browse Groups dialog for searching groups; otherwise, false. Default value is false.

    System.Nullable<System.Boolean> hideFromOutlookClients

    True if the group should not be displayed in Outlook clients, such as Outlook for Windows and Outlook on the web; otherwise, false. Default value is false.

    AzureEnvironment azureEnvironment

    Defines the Azure Cloud Deployment. This is used to determine the MS Graph EndPoint to call which differs per Azure Cloud deployments. Defaults to Production (graph.microsoft.com).

    UpdateGroup(String, String, Int32, Int32, String, String, String[], String[], Nullable<Boolean>, Nullable<Boolean>, AzureEnvironment)

    Updates the Azure Active Directory Group

    Declaration
    public static bool UpdateGroup(string groupId, string accessToken, int retryCount = 10, int delay = 500, string displayName = null, string description = null, string[] owners = null, string[] members = null, bool? securityEnabled = null, bool? mailEnabled = null, AzureEnvironment azureEnvironment = default(AzureEnvironment))
    Parameters
    System.String groupId

    The ID of the Azure Active Directory Group

    System.String accessToken

    The OAuth 2.0 Access Token to use for invoking the Microsoft Graph

    System.Int32 retryCount

    Number of times to retry the request in case of throttling

    System.Int32 delay

    Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry

    System.String displayName

    The Display Name for the Azure Active Directory Group

    System.String description

    The Description for the Azure Active Directory Group

    System.String[] owners

    A list of UPNs for group owners, if any, to be added to the group

    System.String[] members

    A list of UPNs for group members, if any, to be added to the group

    System.Nullable<System.Boolean> securityEnabled

    Boolean indicating if the group is enabled for setting permissions

    System.Nullable<System.Boolean> mailEnabled

    Boolean indicating if the group is enabled for distributing mail

    AzureEnvironment azureEnvironment

    Azure environment to use, needed to get the correct Microsoft Graph URL

    Returns
    System.Boolean

    Boolean indicating whether the Azure Active Directory Group has been updated or not

    Back to top PnP Framework
    Generated by DocFX with Material UI
    spacer