Stay organized with collections
Save and categorize content based on your preferences.
Creating and searching for identity-mapped groups
This page explains how to create and search for identity-mapped groups. An
identity-mapped group is a type of group that mirrors a group in an
external identity source, such as an Active Directory group. Identity-mapped
groups are used when creating an identity connector for Google Cloud Search.
To create an identity-mapped group, call
groups.create() with an
instance of the new group. The group instance must include a groupKey ,
Parent, and label set to system/groups/external. The groupKey is a
combination of namespace and groupId that uniquely identifies the group.
Python
The following example shows a helper function to create an identity group
using the Python client library. Use the identity source ID, obtained when you
created the identity source in the Google Admin console, to call the helper
function and create a group:
defcreate_identity_group(service,identity_source_id,group_id,group_display_name,group_description):namespace="identitysources/"+identity_source_idgroup_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()printresponseexceptException,e:printemyNewGroup=create_identity_group(idSvc,"ABC1234","zebra","Zebra external group","The Zebra group is an identity group representing the Zoolandexternalidentity")
Providing the namespace ensures that you won't experience any naming
collisions, and places the identity-mapped group in the proper context of other
groups from the same external identity source.
Searching for identity-mapped groups
REST
To search for identity-mapped groups, call
groups.search() with a
query string. To search for all groups, you only need to provide the label
system/groups/external.
Python
The following example shows a helper function used to
search for identity-mapped groups using the Python client library:
defsearch_identity_groups(service,identity_source_id,pageSize,view):# Set the label to search for all identity groupssearchQuery="&query=namespace=identitysources/"+identity_source_id \
+"%20AND%20"+"labels:system/groups/external" \
+"&pageSize="+pageSize+"&view="+viewtry:searchGroupsRequest=service.groups().search()searchGroupsRequest.uri+=searchQueryresponse=searchGroupsRequest.execute()printresponseexceptException,e:printe
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eIdentity-mapped groups mirror groups in external identity sources like Active Directory and are used when creating an identity connector for Google Cloud Search.\u003c/p\u003e\n"],["\u003cp\u003eCreating an identity-mapped group involves using the \u003ccode\u003egroups.create()\u003c/code\u003e API method and providing a \u003ccode\u003egroupKey\u003c/code\u003e, \u003ccode\u003eParent\u003c/code\u003e, and \u003ccode\u003elabel\u003c/code\u003e set to \u003ccode\u003esystem/groups/external\u003c/code\u003e, with the \u003ccode\u003egroupKey\u003c/code\u003e uniquely identifying the group through a \u003ccode\u003enamespace\u003c/code\u003e and \u003ccode\u003egroupId\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating the identity group using Python, the namespace must be included to avoid naming conflicts and to ensure the group is in the proper context of the external identity source.\u003c/p\u003e\n"],["\u003cp\u003eSearching for identity-mapped groups is done via the \u003ccode\u003egroups.search()\u003c/code\u003e API method, where providing the \u003ccode\u003esystem/groups/external\u003c/code\u003e label will return all such groups.\u003c/p\u003e\n"],["\u003cp\u003eAfter creating an identity group, the next step is to create memberships, using the procedures described in "Managing identity-mapped group memberships".\u003c/p\u003e\n"]]],[],null,["# Creating and searching for identity-mapped groups\n=================================================\n\nThis page explains how to create and search for *identity-mapped groups*. An\nidentity-mapped group is a type of group that mirrors a group in an\nexternal identity source, such as an Active Directory group. Identity-mapped\ngroups are used when creating an identity connector for Google Cloud Search.\n\nFor more information about identity-mapped groups, see\n[Groups API overview](/identity/docs/groups#group-types).\n\nThe following sections demonstrate how to manage identity-mapped groups.\n\nBefore you begin\n----------------\n\n| **Note:** Before you use any of the Cloud Identity APIs, you must set up Cloud Identity. See [Setting up Cloud Identity](/identity/docs/set-up-cloud-identity-admin) for instructions.\n\nPerform the following tasks before proceeding with the information on this page:\n\n- [Create the identity source](https://support.google.com/a/answer/9039510)\n in the Google Admin console.\n\n- Read the [Groups API overview](/identity/docs/groups).\n\n- [Set up the Groups API](/identity/docs/how-to/setup).\n\nCreating an identity-mapped group\n---------------------------------\n\n### REST\n\nTo create an identity-mapped group, call\n[`groups.create()`](/identity/docs/reference/rest/v1/groups/create) with an\ninstance of the new group. The group instance must include a `groupKey` ,\n`Parent`, and `label` set to `system/groups/external`. The `groupKey` is a\ncombination of `namespace` and `groupId` that uniquely identifies the group.\n\n### Python\n\nThe following example shows a helper function to create an identity group\nusing the Python client library. Use the identity source ID, obtained when you\ncreated the identity source in the Google Admin console, to call the helper\nfunction and create a group: \n\n def create_identity_group(service, identity_source_id, group_id, group_display_name,\n group_description):\n namespace = \"identitysources/\" + identity_source_id\n group_key = {\"id\": group_id, \"namespace\": namespace}\n group = {\n \"parent\": namespace,\n \"description\": group_description,\n \"displayName\": group_display_name,\n \"groupKey\": group_key,\n \"labels\": {\n # Set the label to specify creation of an identity group.\n \"system/groups/external\": \"\"\n }\n }\n\n try:\n response = service.groups().create(body=group).execute()\n print response\n except Exception, e:\n print e\n\n myNewGroup = create_identity_group(\n idSvc,\n \"ABC1234\",\n \"zebra\",\n \"Zebra external group\",\n \"The Zebra group is an identity group representing the Zooland\n external identity\"\n )\n\nProviding the namespace ensures that you won't experience any naming\ncollisions, and places the identity-mapped group in the proper context of other\ngroups from the same external identity source.\n\n### Searching for identity-mapped groups\n\n### REST\n\nTo search for identity-mapped groups, call\n[`groups.search()`](/identity/docs/reference/rest/v1/groups/search) with a\nquery string. To search for all groups, you only need to provide the label\n`system/groups/external`.\n\n### Python\n\nThe following example shows a helper function used to\nsearch for identity-mapped groups using the Python client library: \n\n def search_identity_groups(service, identity_source_id, pageSize, view):\n # Set the label to search for all identity groups\n searchQuery = \"&query=namespace=identitysources/\" + identity_source_id \\\n + \"%20AND%20\" + \"labels:system/groups/external\" \\\n + \"&pageSize=\" + pageSize + \"&view=\" + view\n try:\n searchGroupsRequest = service.groups().search()\n searchGroupsRequest.uri += searchQuery\n response = searchGroupsRequest.execute()\n print response\n except Exception, e:\n print e\n\nWhat's next\n-----------\n\nAfter a group exists, you can create memberships for it. To create memberships\nfor an identity-mapped group, refer to\n[Managing identity-mapped group memberships](/identity/docs/how-to/memberships-identity-groups)."]]