web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Retrieve a user by username (Dynamics CRM 2011)

(0) ShareShare
ReportReport
Posted on by 5

How can I retrieve a user by username? 

This is how I do it using Id:


public virtual MemberAccount Get(Guid id)
        {
            var entity = OrganizationService.Retrieve("Member", id, GetColumnSet());
            var returnEntity = (MemberAccount)Activator.CreateInstance(typeof(MemberAccount), entity);
            return returnEntity;
        }

This how I do it with a query (GetAll):

   public virtual IEnumerable GetAll()
        {
            QueryExpression query = new QueryExpression()
            {
                EntityName = "Member",
                ColumnSet = GetColumnSet(),
            };

            var result = OrganizationService.RetrieveMultiple(query);

            var returnList = new List();

            foreach (var entity in result.Entities)
            {
                returnList.Add((MemberAccount)Activator.CreateInstance(typeof(MemberAccount), entity));
            }

            return returnList;
        }

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    The easiest way is to add a ConditionExpression to your QueryExpression to filter by name:

                                   query.Criteria.AddCondition("fullname", ConditionOperator.Equal, name);

    Where name contains the name you are searching for. Or you could use the BeginsWith or Contains ConditionOperator

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 103 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 83

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans