Google Apps Script

Domain Service

This service allows Google Apps domain administrators to create and modify groups, users, or nicknames. To use this service, you must first enable the Provisioning API for your domain.

// This example creates a new group and adds all of the domain's users to it.
var group = GroupsManager.createGroup('testgroup', 'my new group');
var users = UserManager.getAllUsers();
for (var i in users) {
  group.addMember(users[i].getEmail());
}

Classes

NameBrief description
DomainGroupA Google Apps Domain group.
DomainNicknameA Google Apps Domain nickname.
DomainUserA Google Apps Domain user.
GroupsManagerThis class allows administrators to create, update, retrieve and delete groups in a Google Apps domain.
NicknameManagerThis class allows administrators to create, update, retrieve and delete nicknames in a Google Apps domain.
PermissionLevelEnumeration of the permission levels for Google Groups management operations.
UserManagerThis class allows administrators to create, update, retrieve and delete users in a Google Apps domain.

Class DomainGroup

Methods

MethodReturn typeBrief description
addMember(memberId)DomainGroupAdds a member to the group.
addOwner(ownerId)DomainGroupAdds an owner to the group.
deleteGroup()voidDeletes the group.
getAllMembers()String[]Gets the list of members for the group.
getAllOwners()String[]Gets the list of owners for the group.
getDescription()StringGets the description of the group.
getId()StringGets the group identifier.
getName()StringGets the name of the group.
getPermissionLevel()PermissionLevelGets the permission level of the group.
removeMember(memberId)DomainGroupRemoves a member from the group.
removeOwner(ownerId)DomainGroupRemoves an owner from the group.
setDescription(description)DomainGroupSets the description of the group.
setName(name)DomainGroupSets the name of the group.
setPermissionLevel(level)DomainGroupSets the permission level of the group.

Class DomainNickname

Methods

MethodReturn typeBrief description
deleteNickname()voidDeletes the nickname.
getNickname()StringGets the user's nickname.
getUsername()StringGets the username associated to this nickname.

Class DomainUser

Methods

MethodReturn typeBrief description
deleteUser()voidDeletes the user.
getAgreedToTerms()BooleanIndicates whether the user has agreed to the Terms of Service.
getChangePasswordAtNextLogin()BooleanIndicates whether the system will force the user to change his or her password at the next login.
getEmail()StringGets the user's email address.
getFamilyName()StringGets the user's last name.
getGivenName()StringGets the user's first name.
getIsAdmin()BooleanIndicates whether the user has administrator privileges for the domain.
getIsSuspended()BooleanIndicates whether the user is suspended or active.
getStorageQuota()IntegerGets the amount of storage space allocated to the user account.
setChangePasswordAtNextLogin(changePassword)DomainUserSets whether the system will force the user to change his or her password at the next login.
setFamilyName(name)DomainUserSets the user's last name.
setGivenName(name)DomainUserSets the user's first name.
setIsAdmin(admin)DomainUserSets whether the user has administrator privileges for the domain.
setIsSuspended(suspended)DomainUserSuspends or restores the user's account.
setPassword(password)DomainUserSets the user's password.
setUsername(username)DomainUserSets the username for the account.

Class GroupsManager

Properties

PropertyTypeDescription
PermissionLevelPermissionLevelThe permission level for various group management operations

Methods

MethodReturn typeBrief description
createGroup(groupId, name)DomainGroupCreates a new group for the Google Apps domain.
createGroup(groupId, name, description, permissionLevel)DomainGroupCreates a new group for the Google Apps domain.
getAllGroups()DomainGroup[]Retrieves the list of groups for the Google Apps domain.
getAllGroups(memberId)DomainGroup[]Retrieves the list of groups for a particular member.
getDomain()StringRetrieves the name of the domain being managed.
getGroup(groupId)DomainGroupRetrieves information about a single group for the Google Apps domain.

Class NicknameManager

Methods

MethodReturn typeBrief description
createNickname(username, nickname)DomainNicknameCreates a new nickname for the Google Apps domain user.
getAllNicknames()DomainNickname[]Retrieves the list of nicknames for the Google Apps domain.
getAllNicknames(username)DomainNickname[]Retrieves the list of nicknames for the given user.
getDomain()StringRetrieves the name of the domain being managed.
getNickname(nickname)DomainNicknameRetrieves information about a single nickname for the Google Apps domain.

Class PermissionLevel

Properties

PropertyTypeDescription
ANYONEEnumAnyone can post messages to the group
DOMAINEnumAll domain users can post messages to the group
MEMBEREnumOnly group members can post messages to the group
OWNEREnumOnly group owners can post messages to the group

Class UserManager

Methods

MethodReturn typeBrief description
createUser(username, givenName, familyName, password)DomainUserCreates a new user for the Google Apps domain.
createUser(username, givenName, familyName, password, passwordHashFunction)DomainUserCreates a new user for the Google Apps domain.
getAllUsers()DomainUser[]Retrieves the list of users for the Google Apps domain.
getDomain()StringRetrieves the name of the Google Apps domain being managed.
getUser(username)DomainUserRetrieves information about a single user for the Google Apps domain.
getUser(user)DomainUserRetrieves information about a single user for the Google Apps domain.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.