針對 Classroom 功能指定自訂管理員角色

管理員可在管理控制台中建立自訂管理員角色,允許具備 Education Plus 授權的特定個人或群組執行下列操作:

本指南說明如何使用 Google API,在網域中設定這些功能。

自動執行自訂角色指派程序

如何自動執行自訂角色指派程序:

  1. 建立安全性群組,管理可存取這些功能的使用者。
  2. 在群組中新增成員
  3. 選取適當的權限來建立自訂管理員角色。
  4. 擷取機構單位 ID。
  5. 將自訂管理員角色套用至新建立的群組。

必要條件

  1. 請參閱快速入門指南,瞭解如何使用 JavaScript、Python 和 Java 等 Google API 設定及執行應用程式。
  2. 閱讀 Groups API 總覽
  3. 使用本指南說明的任何 Cloud Identity API 前,您必須先設定 Cloud Identity。這些 API 可用來建立群組,並指派管理員權限。
  4. 設定 Groups API

建立安全性群組

使用 groups.create 方法建立安全性群組。如果要求的 labels 欄位中包含安全性標籤,就可以將群組設為安全性群組。如要進一步瞭解建立安全性群組的相關資訊和限制,請參閱建立安全性群組指南。

POST https://cloudidentity.googleapis.com/v1/groups

您也可以視需要加入 InitialGroupConfig 查詢參數,初始化群組擁有者:

POST https://cloudidentity.googleapis.com/v1/groups&initialGroupConfig={initialGroupConfig}

提出這項要求的帳戶需要下列其中一個範圍:

  • https://www.googleapis.com/auth/cloud-identity.groups
  • https://www.googleapis.com/auth/cloud-identity
  • https://www.googleapis.com/auth/cloud-platform

要求主體

要求主體含有要建立的群組的詳細資料。customerId 的開頭必須是「C」(例如 C046psxkn)。尋找您的客戶 ID

{
   parent: "customers/<customer-id>",
   description: "This is the leadership group of school A.",
   displayName: "Leadership School A",
   groupKey: {
      id: "leadership_school_a@example.com"
   },
   labels: {
      "cloudidentity.googleapis.com/groups.security": "",
      "cloudidentity.googleapis.com/groups.discussion_forum": ""
   }
}

回應

回應包含 Operation 資源的新執行個體。

{
   done: true,
   response: {
      @type: "type.googleapis.com/google.apps.cloudidentity.groups.v1.Group",
      name: "groups/<group-id>", // unique group ID
      groupKey: {
         id: "leadership_school_a@example.com" // group email address
      },
      parent: "customers/<customer-id>",
      displayName: "Leadership School A",
      description: "This is the leadership group of school A.",
      createTime: "<created time>",
      updateTime: "<updated time>",
      labels: {
         "cloudidentity.googleapis.com/groups.security": "",
         "cloudidentity.googleapis.com/groups.discussion_forum": ""
      }
   }
}

新增群組成員

建立群組後,下一步就是新增成員。群組成員可以是使用者或其他安全性群組。如果您將一個群組新增為另一個群組的成員,成員資格最多可能需要 10 分鐘才會傳播。此外,API 也會針對群組成員的週期傳回錯誤。舉例來說,如果 group1group2 的成員,則 group2 不得為 group1 的成員。

如要新增群組成員,請使用下列 POST 要求。

Directory API members.insert

POST https://admin.googleapis.com/admin/directory/v1/groups/{groupKey}/members

groupKey 路徑參數是新成員的群組電子郵件地址或群組的專屬 ID。

提出 POST 要求的帳戶需要下列其中一個範圍:

  • https://apps-apis.google.com/a/feeds/groups/
  • https://www.googleapis.com/auth/admin.directory.group
  • https://www.googleapis.com/auth/admin.directory.group.member

要求主體

要求主體包含要建立的 member 的詳細資料。

{
   email: "person_one@example.com",
   role: "MEMBER", // can be `MEMBER`, `OWNER`, `MANAGER`
}

回應

回應包含成員的新執行個體。

{
   kind: "admin#directory#member",
   etag: "<etag-value>", // role's unique ETag
   id: "4567", // group member's unique ID
   email: "person_one@example.com",
   role: "MEMBER",
   type: "GROUP",
   status: "ACTIVE"
}

此要求必須一一符合資格,才能新增為想新增為成員的使用者。您可以批次處理這些要求,減少用戶端必須建立的 HTTP 連線數量。

建立具有特殊權限的自訂管理員角色

Directory API 可讓您使用角色型存取權控管 (RBAC) 功能,管理 Google Workspace 網域中功能的存取權。您可以建立具有權限的自訂角色,限制管理員權限,而非 Google Workspace 提供的預先建構角色。您可以指派角色給使用者或安全性群組如要進一步瞭解建立角色的限制,請參閱自訂角色和角色指派的限制

如要建立新角色,請使用下列 POST 要求。

Directory API roles.insert

POST https://admin.googleapis.com/admin/directory/v1/customer/{customer}/roles

customerId 與本指南步驟 1 中使用的相同。

提出 POST 要求的帳戶需要下列範圍:

  • https://www.googleapis.com/auth/admin.directory.rolemanagement

要求主體

要求主體包含要建立的 role 的詳細資料。為應透過這個角色授予的每個權限新增 privilegeNameserviceId

Classroom 數據分析

您必須具備 EDU_ANALYTICS_DATA_ACCESS 權限,才能建立可存取數據分析資料的自訂角色,以及將 serviceId 設為 019c6y1840fzfkt 的自訂角色。

{
   roleName: "Education Admin", // customize as needed
   roleDescription: "Access to view analytics data", // customize as needed
   rolePrivileges: [
      {
         privilegeName: "EDU_ANALYTICS_DATA_ACCESS",
         serviceId: "019c6y1840fzfkt"
      }
   ]
}

臨時課程存取權

您必須擁有 ADMIN_OVERSIGHT_MANAGE_CLASSES 權限,才能建立可暫時存取類別的自訂角色,以及將 serviceId 設為 019c6y1840fzfkt 的自訂角色。

{
   roleName: "Education Admin", // customize as needed
   roleDescription: "Access to manage classes privilege", // customize as needed
   rolePrivileges: [
      {
         privilegeName: "ADMIN_OVERSIGHT_MANAGE_CLASSES",
         serviceId: "019c6y1840fzfkt"
      }
   ]
}

呼叫 privileges.list 方法,擷取 privilegeIdsserviceIds 的清單。

回應

回應會包含角色的新執行個體。

Classroom 數據分析

{
   kind: "admin#directory#role",
   etag: "<etag-value>",  // role's unique ETag
   roleId: "<role-id>",   // role's unique ID
   roleName: "Education Admin",
   roleDescription: "Access to view analytics data",
   rolePrivileges: [
      {
         privilegeName: "EDU_ANALYTICS_DATA_ACCESS",
         serviceId: "019c6y1840fzfkt"
      }
   ],
   isSystemRole: false,
   isSuperAdminRole: false
}

臨時課程存取權

{
   kind: "admin#directory#role",
   etag: "<etag-value>",  // role's unique ETag
   roleId: "<role-id>",   // role's unique ID
   roleName: "Education Admin",
   roleDescription: "Access to manage classes privilege",
   rolePrivileges: [
      {
         privilegeName: "ADMIN_OVERSIGHT_MANAGE_CLASSES",
         serviceId: "019c6y1840fzfkt"
      }
   ],
   isSystemRole: false,
   isSuperAdminRole: false
}

擷取機構單位 ID

您可以使用機構單位 ID,將自訂管理員角色的存取權限制為一或多個機構單位。使用 OrgUnit API 擷取 orgUnitId

Classroom 數據分析

將自訂管理員角色指派給特定使用者或群組時,建議您選取學生機構單位「和」老師機構單位。如此一來,具備自訂管理員權限的使用者就能存取機構單位的學生和類別層級資料。如果省略學生機構單位,指定的使用者就無法存取學生資料。如果省略老師機構單位,指定的使用者就無法存取課程層級資料。

臨時課程存取權

若要限制臨時課程存取權,您可以允許具備自訂管理員角色的使用者存取特定機構單位中的課程。如果限制特定機構單位的存取權,指派自訂管理員角色的群組只能存取課程主要任課老師屬於該機構單位的課程。

指派自訂管理員角色

如要將自訂管理員角色指派給群組,請使用下列 POST 要求。如要瞭解角色指派限制,請參閱自訂角色和角色指派限制指南。

Directory API roleAssignments.insert

POST https://admin.googleapis.com/admin/directory/v1/customer/{customer}/roleassignments

指派給群組或個別使用者

如要將權限指派給群組,請在要求主體的 assignedTo 欄位中加入 groupId。您在建立安全性群組步驟中取得了 groupId。如要將權限指派給個別使用者,請在要求主體的 assignedTo 欄位中加入使用者的 ID。如要擷取使用者 ID,您可以呼叫 users.get,並將使用者的電子郵件地址指定為 userKey 參數,或是呼叫 users.list

提出 POST 要求的帳戶需要下列範圍:

  • https://www.googleapis.com/auth/admin.directory.rolemanagement

要求主體

要求主體包含要建立的 RoleAssignment 的詳細資料。您必須為每個要與這個群組建立關聯的機構單位提出一個要求。

{
   roleId: "<role-id>",        // role's unique ID obtained from Step 3
   assignedTo: "<id>",         // group ID or user ID
   scopeType: "ORG_UNIT",      // can be `ORG_UNIT` or `CUSTOMER`
   orgUnitId: "<org-unit-id>"  // organizational unit ID referenced in Step 4
}

回應

回應會包含 RoleAssignment 的新執行個體。

{
   kind: "admin#directory#roleAssignment",
   etag: "<etag-value>",
   roleAssignmentId: "<role-assignment-id>",
   roleId: "<role-id>",
   assignedTo: "<group-id or user-id>",
   assigneeType: "GROUP",
   scopeType: "ORG_UNIT",
   orgUnitId: "<org-unit-id>"
}

資源

如需更多資訊,請前往: