This article explains how to query Salesforce to determine whether a specific Contact record is associated with a Customer Portal or Experience Cloud user account. This is useful when troubleshooting access issues, verifying community user setup, or auditing portal user assignments.
Note: "Portal User" is legacy terminology. The current term is Experience Cloud User.
Use the following SOQL query in the Developer Console to check whether a specific Contact is associated with a Customer Portal User profile. Replace 003xxxxxxxxxxxxxxx with the actual Contact ID you want to check.
SELECT Id, Name, Email
FROM User
WHERE Profile.Name = 'Customer Portal User'
AND ContactId = '003xxxxxxxxxxxxxxx'
If the query returns a result, the Contact has an active portal/Experience Cloud user account. If no results are returned, the Contact is not a portal user.
To check whether multiple Contacts are portal users, use the following Apex snippet in the Developer Console's Execute Anonymous window:
List<Contact> lContacts = [SELECT Id FROM Contact];
List<User> lUsers = [SELECT Id, Contact.Id, Name, Email
FROM User
WHERE Profile.Name = 'Customer Portal User'
AND ContactId IN :lContacts];
NOTE: The first SOQL query on Contact must be scoped (filtered) to avoid hitting Apex Governor Limits. Without a WHERE clause, this query will return all Contact records and may exceed the 50,000-row Apex Governor limits. Always filter by a specific set of Contact IDs or a field condition.
000386163

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.