Click here to Skip to main content
Licence CPOL
First Posted 29 Oct 2007
Views 14,360
Bookmarked 11 times

How to Retrieve the System User List Efficiently

By | 9 Oct 2009 | Article
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

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralFix Grammar PinmemberRi Qen-Sin14:41 29 Oct '07  
GeneralRe: Fix Grammar PinmemberOshri Cohen9:21 30 Oct '07  

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.

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