AddSharedDriveMember Method

Creates a new shared drive member.

Syntax

QString AddSharedDriveMember(const QString& qsSharedDriveId, int iRole, int iPermissionType, const QString& qsEmail);

Remarks

This is a convenience method that adds a new member to the shared drive specified by SharedDriveId by creating a permission on that shared drive. The Id of the newly-created permission is returned.

Role specifies the member's role. Valid values are:

prReader (0) Read-only permissions.
prCommenter (1) Read-only plus commenting permissions.
prWriter (2) Read, write, and comment permissions.
prFileOrganizer (4) Writer permissions, plus the ability to move and trash resources.
prOrganizer (5) File organizer permissions, plus the ability to permanently delete resources from, and rename/delete/alter the membership of, a shared drive.

PermissionType must be one of:

  • 0 (ptUser) - A single user.
  • 1 (ptGroup) - A group.

Email specifies the email address of the user or the group.

Refer to UpdatePermissions for more information about how permissions work in general, how permissions relate to shared drive members, and how to manipulate multiple members at once.

string sharedDriveId = "20983euijdsds";
// First, we'll add a new member to the shared drive. The two integer parameters signify:
// * The role type. 2 is the "Writer" role, which provides read and write (but not organize) permissions.
// * The permission type. 0 means this is a single user (versus a group).
// The Id of the new permission we've created on the shared drive--which is what actually causes the user to
// be a member of the shared drive--is returned.
string permId = googledrive.AddSharedDriveMember(sharedDriveId, 2, 0, "fakeuser@example.com");

// At some point later, perhaps this user has abused their privileges and we wish to revoke their writer
// permissions. We change their role to "Commenter", which provides reader and commenting permissions.
googledrive.UpdateSharedDriveMember(sharedDriveId, permId, 1); // 1 is the "Commenter" role.

// Or perhaps we wish to simply remove the user's shared drive membership completely.
googledrive.RemoveSharedDriveMember(sharedDriveId, permId);

Error Handling

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Qt Edition - Version 20.0 [Build 8265]