Find the Teams for a User

CRM 1.0

This sample retrieves a list of teams to which the user belongs.

Class Reference

Schema Reference

  • team.xsd



// The precondition for this code to work is that there needs to be
// an organization, a business unit within the organization, and a user
// within the business unit whose 'domainname' corresponds to the 
// Active Directory name of the currently logged on user

public void RetrieveTeamsOfUser()
   // strServer should be set with the name of the platform Web server
   String strServer = "MyServerName";

   // strVirtualDirectory should be set with the name of the Microsoft CRM
   // virtual directory on the platform Web server
   String strVirtualDirectory = "mscrmservices";
   String strDir = String.Concat("http://", strServer, "/",
                                 strVirtualDirectory, "/");

   // BizUser proxy object
   Microsoft.Crm.Platform.Proxy.BizUser bizUser 
               = new Microsoft.Crm.Platform.Proxy.BizUser ();
   bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
   bizUser.Url = String.Concat(strDir, "BizUser.srf");

   String strErrorMsg;
      Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();

      // ColumnSetXML specifies which columns to retrieve for the team

      // For simple usage, setting ColumnSetXML to empty string will
      // return all columns
      String columnSetXML = "<columnset><column>teamid</column></columnset>";

      String teamsXML = bizUser.RetrieveTeams(userAuth,
                                          userAuth.UserId, columnSetXML);
   catch (System.Web.Services.Protocols.SoapException err)
      // Process the platform error here
      strErrorMsg = String.Concat("ErrorMessage: ", err.Message, " ",
                      err.Detail.OuterXml, " Source: ", err.Source);

© 2005 Microsoft Corporation. All rights reserved.