---
schema_version: "1"
id: f9db4b5dcf190a7889e4b3324ad98058c43505b5193d8ae5e7def5b16da8d367
title: CommunitiesUtil Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Auth_CommunitiesUtil.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_CommunitiesUtil.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1d1e63c4e5be30939dbc5a0bc8b49feaddba3cf920c96341881cee31a6447b4b
description: Contains methods for getting information about an Experience Cloud user.Returns the page to display after the current Experience Cloud user logs out.Returns the current user’s Experience Cloud display name.Indicates whether the current user isn’t logged in to the Experience Cloud site. Redirect the user to log in, if necessary.Indicates whether the current user is logged in as a member of the parent Salesforce organization, such as an employee.
---
# CommunitiesUtil Class

Contains methods for getting information about an Experience Cloud user.

## Namespace

[Auth](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Auth.htm "The Auth namespace provides an interface and classes for single sign-on into Salesforce and session security management.")

## Example

The following example directs a guest (unauthenticated) user to one page, and authenticated users of the Experience Cloud site’s parent organization to another page.

if (Auth.CommunitiesUtil.isGuestUser())
    // Redirect to the login page if user is an unauthenticated user
    return new PageReference(LOGIN\_URL);       

if (Auth.CommunitiesUtil.isInternalUser())
    // Redirect to the home page if user is an internal user
    return new PageReference(HOME\_URL);       

## CommunitiesUtil Methods

The following are methods for CommunitiesUtil. All methods are static.

- **[getLogoutUrl()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_CommunitiesUtil.htm#apex_Auth_CommunitiesUtil_getLogoutUrl)**  
    Returns the page to display after the current Experience Cloud user logs out.
- **[getUserDisplayName()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_CommunitiesUtil.htm#apex_Auth_CommunitiesUtil_getUserDisplayName)**  
    Returns the current user’s Experience Cloud display name.
- **[isGuestUser()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_CommunitiesUtil.htm#apex_Auth_CommunitiesUtil_isGuestUser)**  
    Indicates whether the current user isn’t logged in to the Experience Cloud site. Redirect the user to log in, if necessary.
- **[isInternalUser()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_CommunitiesUtil.htm#apex_Auth_CommunitiesUtil_isInternalUser)**  
    Indicates whether the current user is logged in as a member of the parent Salesforce organization, such as an employee.

### getLogoutUrl()

Returns the page to display after the current Experience Cloud user logs out.

#### Signature

public static String getLogoutUrl()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getUserDisplayName()

Returns the current user’s Experience Cloud display name.

#### Signature

public static String getUserDisplayName()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### isGuestUser()

Indicates whether the current user isn’t logged in to the Experience Cloud site. Redirect the user to log in, if necessary.

#### Signature

public static Boolean isGuestUser()

#### Return Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### isInternalUser()

Indicates whether the current user is logged in as a member of the parent Salesforce organization, such as an employee.

#### Signature

public static Boolean isInternalUser()

#### Return Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")