class Program
{
static void Main(string[]
args)
{
String userName;
String password;
String organizationUrl;
userName = <your-Live-ID>;
password = <Live-ID-Password>;
organizationUrl = "https://<your-org-name>.crm.dynamics.com/XRMServices/2011/Organization.svc";
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = userName;
credentials.UserName.Password = password;
OrganizationServiceProxy _serviceProxy;
IOrganizationService _service;
using
(_serviceProxy = new OrganizationServiceProxy(
new Uri(organizationUrl),
null,
credentials,
Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice()))
{
_service = (IOrganizationService)_serviceProxy;
WhoAmIResponse response =
(WhoAmIResponse)_service.Execute(new WhoAmIRequest());
Console.WriteLine(response.UserId.ToString());
}
Console.ReadLine();
}
}
Thanks!
ReplyDeleteYou have 2 equal lines:
credentials.UserName.UserName = userName;
Thank you! Fixed this
ReplyDeleteThis comment has been removed by the author.
ReplyDelete