Google Apps Script

Class DomainUser

A Google Apps Domain user.

Only Google Apps Domain administrators are allowed to use this class.

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.

Detailed documentation

deleteUser()

Deletes the user.

 
var user = UserManager.getUser("john.smith");
 user.deleteUser();
 

getAgreedToTerms()

Indicates whether the user has agreed to the Terms of Service.

 
var user = UserManager.getUser("john.smith");
 var agreedToTerms = user.getAgreedToTerms();
 

Return

Boolean — whether the user has agreed to the Terms of Service


getChangePasswordAtNextLogin()

Indicates whether the system will force the user to change his or her password at the next login.

 
var user = UserManager.getUser("john.smith");
 var mustChangePassword = user.getChangePasswordAtNextLogin();
 

Return

Boolean — whether the user will have to change his or her password at the next login


getEmail()

Gets the user's email address. If the user's email address is not available, this method returns a blank string.

Return

String — the user's email's address, or a blank string if the email address is not available


getFamilyName()

Gets the user's last name.

 
var user = UserManager.getUser("john.smith");
 var familyName = user.getFamilyName();
 

Return

String — the user's last name


getGivenName()

Gets the user's first name.

 
var user = UserManager.getUser("john.smith");
 var firstName = user.getGivenName();
 

Return

String — the user's first name


getIsAdmin()

Indicates whether the user has administrator privileges for the domain.

 
var user = UserManager.getUser("john.smith");
 var isAdmin = user.getIsAdmin();
 

Return

Boolean — whether the user has administrative privileges for the domain


getIsSuspended()

Indicates whether the user is suspended or active.

 
var user = UserManager.getUser("john.smith");
 var isSuspended = user.getIsSuspended();
 

Return

Boolean — whether the user is suspended or not


getStorageQuota()

Gets the amount of storage space allocated to the user account.

 
var user = UserManager.getUser("john.smith");
 var quota = user.getStorageQuota();

 

Return

Integer — the amount of disk space in MB allocated to the user account


setChangePasswordAtNextLogin(changePassword)

Sets whether the system will force the user to change his or her password at the next login.

 
// Instructs the system to force the user to change their password at the next login.
 var user = UserManager.getUser("john.smith").setChangePasswordAtNextLogin(true);
 

Parameters

NameTypeDescription
changePasswordBooleanwhether the user will have to change his or her password at the next login

Return

DomainUser — the updated user


setFamilyName(name)

Sets the user's last name.

 
// Sets the user's last name to "Brown".
 var user = UserManager.getUser("john.smith").setFamilyName("Brown");
 

Parameters

NameTypeDescription
nameStringthe new last name for the user

Return

DomainUser — the updated user


setGivenName(name)

Sets the user's first name.

 
// Sets the user's first name to "Jack".
 var user = UserManager.getUser("john.smith").setGivenName("Jack");
 

Parameters

NameTypeDescription
nameStringthe new first name for the user

Return

DomainUser — the updated user


setIsAdmin(admin)

Sets whether the user has administrator privileges for the domain.

 
// Sets the user as an administrator for the domain.
 var user = UserManager.getUser("john.smith").setIsAdmin(true);
 

Parameters

NameTypeDescription
adminBooleanwhether the user will have administrator privileges for the domain

Return

DomainUser — the updated user


setIsSuspended(suspended)

Suspends or restores the user's account.

 
// Suspends the user's account.
 var user = UserManager.getUser("john.smith").setIsSuspended(true);
 

Parameters

NameTypeDescription
suspendedBooleanwhether the user will be suspended or not

Return

DomainUser — the updated user


setPassword(password)

Sets the user's password.

 
// Sets the user's password to "newpassword".
 var user = UserManager.getUser("john.smith").setPassword("newpassword");
 

Parameters

NameTypeDescription
passwordStringthe new password for the user

Return

DomainUser — the updated user


setUsername(username)

Sets the username for the account. This value must be unique within the domain.

 
// Sets the username to "jsmith".
 var user = UserManager.getUser("john.smith").setUsername("jsmith");
 

Parameters

NameTypeDescription
usernameStringthe new username for the account

Return

DomainUser — the updated user

Deprecated methods


Authentication required

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

Signing you in...

Google Developers needs your permission to do that.