建立及搜尋識別資訊對應群組
本頁說明如何建立及搜尋識別資訊對應群組。識別資訊對應群組是一種群組,可鏡像處理外部識別資訊來源中的群組,例如 Active Directory 群組。為 Google Cloud Search 建立識別資訊連接器時,會使用身分對應群組。
如要進一步瞭解已對應身分的群組,請參閱「Groups API 總覽」。
以下各節說明如何管理身分對應群組。
事前準備
請先完成下列工作,再按照本頁資訊操作:
在 Google 管理控制台中建立識別資訊來源。
參閱 Groups API 總覽。
建立識別資訊對應群組
REST
如要建立識別資訊對應群組,請使用新群組的執行個體呼叫 groups.create()。群組執行個體必須包含 groupKey、Parent 和 label,且這些值都設為 system/groups/external。groupKey 是 namespace 和 groupId 的組合,可做為群組的專屬 ID。
Python
以下範例顯示如何使用 Python 用戶端程式庫建立身分群組的輔助函式。使用在 Google 管理控制台中建立識別資訊來源時取得的識別資訊來源 ID,呼叫輔助函式並建立群組:
def create_identity_group(service, identity_source_id, group_id, group_display_name,
group_description):
namespace = "identitysources/" + identity_source_id
group_key = {"id": group_id, "namespace": namespace}
group = {
"parent": namespace,
"description": group_description,
"displayName": group_display_name,
"groupKey": group_key,
"labels": {
# Set the label to specify creation of an identity group.
"system/groups/external": ""
}
}
try:
response = service.groups().create(body=group).execute()
print response
except Exception, e:
print e
myNewGroup = create_identity_group(
idSvc,
"ABC1234",
"zebra",
"Zebra external group",
"The Zebra group is an identity group representing the Zooland
external identity"
)
提供命名空間可確保不會發生任何命名衝突,並將識別資訊對應群組放在來自相同外部識別資訊來源的其他群組適當脈絡中。
搜尋識別資訊對應群組
REST
如要搜尋識別資訊對應群組,請使用查詢字串呼叫 groups.search()。如要搜尋所有群組,只需提供標籤 system/groups/external。
Python
以下範例顯示用來使用 Python 用戶端程式庫搜尋身分對應群組的輔助函式:
def search_identity_groups(service, identity_source_id, pageSize, view):
# Set the label to search for all identity groups
searchQuery = "&query=namespace=identitysources/" + identity_source_id \
+ "%20AND%20" + "labels:system/groups/external" \
+ "&pageSize=" + pageSize + "&view=" + view
try:
searchGroupsRequest = service.groups().search()
searchGroupsRequest.uri += searchQuery
response = searchGroupsRequest.execute()
print response
except Exception, e:
print e
後續步驟
群組建立完成後,即可建立成員資格。如要為識別資訊對應群組建立成員資格,請參閱「管理識別資訊對應群組的成員資格」。