示例#1
0
        private static void ExecuteWhoAmI(ClientCredentials credentials, string serviceUrl)
        {
            using (OrganizationServiceClient client = new OrganizationServiceClient("CustomBinding_IOrganizationService", new EndpointAddress(serviceUrl)))
            {
                ApplyCredentials(client, credentials);

                OrganizationRequest request = new OrganizationRequest();
                request.RequestName = "WhoAmI";

                OrganizationResponse response = (OrganizationResponse)client.Execute(request);

                foreach (KeyValuePair <string, object> result in response.Results)
                {
                    if ("UserId" == result.Key)
                    {
                        Console.WriteLine("User ID: {0}", result.Value);
                        break;
                    }
                }
            }
        }
示例#2
0
文件: Program.cs 项目: weedkiller/crm
        private static void ExecuteWhoAmI(SecurityToken token, string serviceUrl, Uri issuerUri)
        {
            using (OrganizationServiceClient client = new OrganizationServiceClient("CustomBinding_IOrganizationService",
                                                                                    new EndpointAddress(serviceUrl)))
            {
                client.ConfigureCrmOnlineBinding(issuerUri);
                client.Token = token;

                OrganizationRequest request = new OrganizationRequest();
                request.RequestName = "WhoAmI";

                OrganizationResponse response = (OrganizationResponse)client.Execute(request);

                foreach (KeyValuePair <string, object> result in response.Results)
                {
                    if ("UserId" == result.Key)
                    {
                        Console.WriteLine("User ID: {0}", result.Value);
                        break;
                    }
                }
            }
        }
示例#3
0
        private static void ExecuteWhoAmI(SecurityToken token, string serviceUrl, Uri issuerUri)
        {
            using (OrganizationServiceClient client = new OrganizationServiceClient("CustomBinding_IOrganizationService",
                new EndpointAddress(serviceUrl)))
            {
                client.ConfigureCrmOnlineBinding(issuerUri);
                client.Token = token;

                OrganizationRequest request = new OrganizationRequest();
                request.RequestName = "WhoAmI";

                OrganizationResponse response = (OrganizationResponse)client.Execute(request);

                foreach (KeyValuePair<string, object> result in response.Results)
                {
                    if ("UserId" == result.Key)
                    {
                        Console.WriteLine("User ID: {0}", result.Value);
                        break;
                    }
                }
            }
        }