Deprecated. The Domain service was deprecated on May 15, 2014, and will be turned off on November 20, 2014. To manage your domain, use the Admin SDK Directory and Admin SDK Reports advanced services instead. See the guide to migrating from Domain service.
This class allows administrators to create, update, retrieve and delete users in a Google Apps domain.
To use this class you have to first enable the Provisioning API on 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());
}
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| | Creates a new user for the Google Apps domain. |
| | Creates a new user for the Google Apps domain. |
| | Creates a new user for the Google Apps domain {@code // Creates a new user "john.smith" and sets the initial password as an MD5 hash value. |
| | Retrieves the list of users for the Google Apps domain. |
| String | Retrieves the name of the Google Apps domain being managed. |
| | Retrieves information about a single user for the Google Apps domain. |
| | Retrieves information about a single user for the Google Apps domain. |
Deprecated methods
createUser(username, givenName, familyName, password)
createUser(username, givenName, familyName, password)Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new user for the Google Apps domain.
// Creates a new user "john.smith" and sets the initial password.
var user = UserManager.createUser("john.smith", "John", "Smith", "theInitialPw");
Parameters
| Name | Type | Description |
|---|---|---|
username | String | the unique name that identifies the account |
givenName | String | the user's first name |
familyName | String | the user's last name |
password | String | the password for the account |
Return
— the created userDomainUser
createUser(username, givenName, familyName, password, passwordHashFunction)
createUser(username, givenName, familyName, password, passwordHashFunction)Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new user for the Google Apps domain.
// Creates a new user "john.smith" and sets the initial password as an MD5 hash value.
var user = UserManager.createUser("john.smith", "John", "Smith",
"5f4dcc3b5aa765d61d8327deb882cf99", Utilities.DigestAlgorithm.MD5);
Parameters
| Name | Type | Description |
|---|---|---|
username | String | the unique name that identifies the account |
givenName | String | the user's first name |
familyName | String | the user's last name |
password | String | the password for the account |
passwordHashFunction | DigestAlgorithm | the hash format of the password parameter |
Return
— the created userDomainUser
See also
createUser(username, givenName, familyName, password, passwordHashFunction, quotaLimitInMb)
createUser(username, givenName, familyName, password, passwordHashFunction, quotaLimitInMb)Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new user for the Google Apps domain
// Creates a new user "john.smith" and sets the initial password as an MD5 hash value.
var user = UserManager.createUser("john.smith", "John", "Smith",
"5f4dcc3b5aa765d61d8327deb882cf99", DigestAlgorithm.MD5, 1024);
Parameters
| Name | Type | Description |
|---|---|---|
username | String | the unique name that identifies the account |
givenName | String | the user's first name |
familyName | String | the user's last name |
password | String | the password for the account. If the passwordHashFunction parameter is defined, this should be the hashed value of the password in the corresponding hash format. |
passwordHashFunction | DigestAlgorithm | the hash format of the password parameter |
quotaLimitInMb | Integer | the amount of disk space in MB that will be allocated to the user account |
Return
— the created userDomainUser
See also
getAllUsers()
getAllUsers()Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves the list of users for the Google Apps domain.
// Logs the emails of all of the domain's users.
var users = UserManager.getAllUsers();
for (var i in users) {
Logger.log(users[i].getEmail());
}
Return
— an array of all of the domain's usersDomainUser[]
getDomain()
getDomain()Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves the name of the Google Apps domain being managed.
var domainName = UserManager.getDomain();
Return
String — the name of the domain being managed
getUser(username)
getUser(username)Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves information about a single user for the Google Apps domain.
var user = UserManager.getUser("john.smith");
Parameters
| Name | Type | Description |
|---|---|---|
username | String | the unique name that identifies the account |
Return
— the retrieved user accountDomainUser
getUser(user)
getUser(user)Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves information about a single user for the Google Apps domain.
// Gets the domain user object for the current user.
var user = UserManager.getUser(Session.getUser());
Parameters
| Name | Type | Description |
|---|---|---|
user | User | the user entry identifying the account |
Return
— the retrieved user accountDomainUser