為動態群組建立成員查詢

如要在 Google 管理控制台中建立動態群組的成員查詢,您可以使用預設標準屬性、您建立的自訂屬性,也可以兩種屬性一併使用。

本頁內容

使用標準屬性

在管理控制台建立動態群組時,請從「條件」清單中選取標準屬性。您可以使用下表中的所有屬性,建立動態群組的成員資格查詢。

屬性

程式碼範例

國家/地區

addresses.country

user.addresses.exists(address, address.country == 'Canada')

國家/地區代碼

addresses.country_code

user.addresses.exists(address, address.country_code == '555')

自訂地址類型

addresses.custom_type

user.addresses.exists(address, address.custom_type=='Custom address type')

詳細地址

addresses.extended_address

user.addresses.exists(address, address.extended_address=='California, USA')

地址縣市

addresses.locality

user.addresses.exists(address, address.locality=='Southern California')

郵遞區號

addresses.postal_code

user.addresses.exists(address, address.postal_code=='94040')

郵政信箱

addresses.po_box

user.addresses.exists(address, address.po_box=='87132')

是否為主要地址

addresses.primary

user.addresses.exists(address, address.primary==true)

地區

addresses.region

user.addresses.exists(address, address.region=='Southwest')

街道地址

addresses.street_address

user.addresses.exists(address, address.street_address=='123 Fake St')

地址類型

addresses.type

user.addresses.exists(address, address.type==1)

電子郵件地址

emails.address

user.emails.exists(email, email.address.startsWith(''))

自訂電子郵件類型

emails.custom_type

email.address.startsWith('custom@google.com')

是否為主要電子郵件

emails.primary

user.emails.exists(email, email.primary==true)

電子郵件類型

emails.type

user.emails.exists(email, email.type==1)

自訂外部 ID 類型

external_ids.custom_type

user.external_ids.exists(id, id.custom_type.startsWith('runner'))

外部 ID 類型

external_ids.type

user.external_ids.exists(id, id.type==3)

外部 ID

external_ids.value

user.external_ids.exists(id, id.value=='')

性別代名詞

gender.address_me_as

user.gender.address_me_as=='they/them'

自訂性別類型

gender.custom_gender

user.gender.custom_gender.startsWith('custom gender')

性別類型

gender.type

user.gender.type==3

自訂 IMS 通訊協定

ims.custom_protocol

user.ims.exists(im, im.custom_protocol.startsWith('custom'))

自訂 IMS 類型

ims.custom_type

user.ims.exists(im, im.custom_type.startsWith('custom'))

標準 IMS 通訊協定

ims.standard_protocol

user.ims.exists(im, im.standard_protocol==7)

是否為主要 IMS

ims.primary

user.ims.exists(im, im.primary==true)

IMS 類型

ims.type

user.ims.exists(im, im.type==3)

即時通訊程式

ims.value

user.ims.exists(im, im.value=='chat')

自訂關鍵字類型

keywords.custom_type

user.keywords.exists(keyword, keyword.custom_type.startsWith('contractor'))

關鍵字類型

keywords.type

user.keywords.exists(keyword, keyword.type==3)

關鍵字

keywords.value

user.keywords.exists(keyword, keyword.value=='engineer')

語言代碼

languages.language_code

user.languages.exists(language, language.language_code=='English')

位置區域

locations.area

user.locations.exists(loc, loc.area=='Near San Francisco')

建築物 ID

locations.building_id

user.locations.exists(loc, loc.building_id=='')

自訂位置類型

locations.custom_type

user.locations.exists(loc, loc.custom_type=='Region')

辦公桌代碼

locations.desk_code

user.locations.exists(loc, loc.desk_code=='Desk 37')

樓層名稱

locations.floor_name

user.locations.exists(loc, loc.floor_name=='')

地板區塊

locations.floor_section

user.locations.exists(loc, loc.floor_section=='')

位置類型

locations.type

user.locations.exists(loc, loc.type==1)

姓氏

name.family_name

user.name.family_name==''

名字

name.given_name

user.name.given_name==''

名稱

name.value

user.name.value==''

成本中心

organizations.cost_center

user.organizations.exists(org, org.cost_center=='')

自訂機構類型

organizations.custom_type

user.organizations.exists(org, org.custom_type=='nonprofit')

部門

organizations.department

user.organizations.exists(org, org.department=='')

員工類型

organizations.description

user.organizations.exists(org, org.description=='search provider')

網域

organizations.domain

user.organizations.exists(org, org.domain=='example.net')

機構所在地

organizations.location

user.organizations.exists(org, org.location=='California')

機構名稱

organizations.name

user.organizations.exists(org, org.name=='Google')

是否為主要機構

organizations.primary

user.organizations.exists(org, org.primary==true)

機構代號

organizations.symbol

user.organizations.exists(org, org.symbol=='GOOG')

職稱

organizations.title

user.organizations.exists(org, org.title=='')

機構類型

organizations.type

user.organizations.exists(org, org.type==2)

自訂電話類型

phones.custom_type

user.phones.exists(phone, phone.custom_type.startsWith('new type'))

是否為主要電話

phones.primary

user.phones.exists(phone, phone.primary==true)

手機類型

phones.type

user.phones.exists(phone, phone.type==11)

電話號碼

phones.value

user.phones.exists(phone, phone.value=='')

自訂關係類型

relations.custom_type

user.relations.exists(rel, rel.custom_type=='example')

關係值

relations.value

user.relations.exists(rel, rel.value=='Sundar')

關係類型

relations.type

user.relations.exists(rel, rel.type==12)

自訂網站類型

websites.custom_type

user.websites.exists(site, site.custom_type.startsWith('creative writing'))

是否為主要網站

websites.primary

user.websites.exists(site, site.primary==true)

網站類型

websites.type

user.websites.exists(site, site.type==2)

網站

websites.value

user.websites.exists(site, site.value=='google.com')

祖系機構單位

org_units.org_unit_id

user.org_units.exists(org_unit, org_unit.org_unit_id==orgUnitId(''))

主管的電子郵件地址

managers.user_id

user.managers.exists(manager, manager.user_id==userId(''))

已封存

已封存

user.archived==true

登入時變更密碼

change_password_at_next_login

user.change_password_at_next_login==true

已強制實行兩步驟驗證

is_2sv_enforced

user.is_2sv_enforced==true

已啟用兩步驟驗證

is_enrolled_in_2sv

user.is_enrolled_in_2sv==true

是否已設定信箱

is_mailbox_setup

user.is_mailbox_setup==true

主要電子郵件

primary_email

user.primary_email==''

已遭停權

已停權

user.suspended==true

停權原因

suspension_reason

user.suspension_reason==4

上層機構單位

org_unit_id

user.org_unit_id==orgUnitId('')

性別

Gender.Gender

user.custom_schemas.Gender.Gender.exists(G, G=='')

種族

Ethnicity.Ethnicity

user.custom_schemas.Ethnicity.Ethnicity.exists(E, E=='')

使用自訂屬性

在管理控制台中建立成員資格查詢時,自訂屬性會顯示在「條件」清單的標準屬性之後。

如果您執行的查詢含有自訂屬性,而且查詢沒有傳回任何成員,則屬性可能在 Groups API 中設定有誤。具體來說,您必須將「indexed」屬性設為 true。詳情請參閱「自訂使用者屬性」。

自動將使用者加入動態群組

您可以編輯使用者的帳戶資訊,讓資訊符合查詢條件,自動將使用者加入動態群組。您可以使用 Directory API,編輯使用者的任何帳戶詳細資料。詳情請參閱「更新使用者帳戶」。

您也可以在管理控制台 (通常是「使用者」頁面) 中,編輯部分使用者帳戶詳細資料,包括:

已強制實行兩步驟驗證 已註冊兩步驟驗證
地址類型 祖系組織單位
建築物 ID 登入時變更密碼
成本中心 部門
電子郵件地址 電子郵件類型
外部 ID 名字
樓層名稱 樓層分區
已封存 是否為主要電子郵件
是否已設定信箱 已遭停權
職稱 姓氏
管理員使用者 ID 名稱
上層組織單位 電話號碼
電話類型

將使用者從動態群組中排除

如果只想加入不符合條件的使用者,請為動態群組建立條件,然後按一下「排除」圖示 。舉例來說,如要建立群組,並將成員限制為不住在美國的使用者,您可以建立「國家/地區代碼等同於美國」條件,然後按一下「排除」圖示 。在查詢中,已排除的使用者會顯示為驚嘆號 (!)。

部分包含「exists」參數的自訂查詢無法使用排除選項。詳情請參閱「設計及測試查詢」。