Click here to Skip to main content
Click here to Skip to main content

How to Retrieve the System User List Efficiently

, 9 Oct 2009
Rate this:
Please Sign up or sign in to vote.
How to retrieve the system user list efficiently from Microsoft CRM 3.0.

Introduction

Ever wondered how to retrieve the User list from Microsoft CRM 3.0? Well, this tutorial will guide you step by step.

Background

I needed to get a list of all users in a CRM 3.0 system for a custom application, so I decided to utilize the Fetch feature of the Microsoft CRM 3.0 Web Service.

Using the code

Use this XML data to "fetch" the CRM users list:

<fetch mapping='logical'>
    <entity name='systemuser'>
        <all-attributes/>
    </entity>
</fetch>

The next part is to send this request and have the CRM return the result set.

  1. Load the result set into an XmlDocument object.
  2. Use the SelectNodes method to get the result set.
  3. CRM will return the actual data in this format "resultset/result", it is the "result" table that holds the needed data.

  4. Iterate through the returned XmlNodeList and do what you need to do with the data.

In the following example, I am building a drop down list:

string result = service.Fetch(fetchxml);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(result);
XmlNodeList userList = xdoc.SelectNodes("resultset/result");
foreach(XmlNode n in userList)  
{  
    ListItem itm = new ListItem();
    itm.Text = n["fullname"].InnerText;
    itm.Value = n["systemuserid"].InnerText;
    ddlUserList.Items.Add(itm);
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Oshri Cohen
Web Developer
Canada Canada
No Biography provided

Comments and Discussions

 
GeneralFix Grammar PinmemberRi Qen-Sin29-Oct-07 14:41 
GeneralRe: Fix Grammar PinmemberOshri Cohen30-Oct-07 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 9 Oct 2009
Article Copyright 2007 by Oshri Cohen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid