{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/comments/154175450","pull_request_review_id":80299939,"id":154175450,"diff_hunk":"@@ -0,0 +1,80 @@\n+﻿using AuthenticationUtility;\n+using System;\n+using System.Collections.Generic;\n+using System.IO;\n+using System.Net;\n+using System.Net.Security;\n+using System.Web;\n+using System.Security.Authentication;\n+using System.Text;\n+using System.Security.Cryptography.X509Certificates;\n+\n+namespace OAuthXppConsoleApplication\n+{\n+    class Program\n+    {\n+        public static string sessionUrl = \"/api/services/UserSessionService/AifUserSessionService/GetUserSessionInfo\";\n+        \n+        static void Main(string[] args)\n+        {\n+            string GetUserSessionOperationPath = string.Format(\"{0}{1}\", ClientConfiguration.Default.UriString.TrimEnd('/'), sessionUrl);\n+            \n+            try\n+            {\n+                // Creates an HttpWebRequest for user session URL\n+                HttpWebRequest aadRequest = (HttpWebRequest) WebRequest.Create(GetUserSessionOperationPath);\n+\n+                // Change TLS version of HTTP request if the TLS version value is defined in ClientConfiguration\n+                if (!string.IsNullOrWhiteSpace(ClientConfiguration.OneBox.TLSVersion))\n+                {\n+                    aadRequest.ProtocolVersion = Version.Parse(ClientConfiguration.OneBox.TLSVersion);\n+                }\n+\n+                string tlsRequestVersion = aadRequest.ProtocolVersion.ToString();                \n+                Console.WriteLine(\"The TLS protocol version for the HTTP request is {0}.\", tlsRequestVersion);\n+                \n+                aadRequest.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader();\n+                aadRequest.Method = \"POST\";\n+                aadRequest.ContentLength = 0;\n+\n+                // Get HttpWebResponse for the response\n+                var aadResponse = (HttpWebResponse) aadRequest.GetResponse();\n+\n+                string tlsResponseVersion = aadResponse.ProtocolVersion.ToString();\n+                Console.WriteLine(\"The TLS protocol version of the server response is {0}.\", tlsResponseVersion);\n+\n+                if (aadResponse.StatusCode != HttpStatusCode.OK)\n+                {\n+                    Console.WriteLine(\"Could not get response from the server.\");\n+                    Console.ReadLine();\n+                    return;\n+                }\n+\n+                // Get response string\n+                using (Stream responseStream = aadResponse.GetResponseStream())\n+                {\n+                    using (StreamReader streamReader = new StreamReader(responseStream))\n+                    {\n+                        string responseString = streamReader.ReadToEnd();\n+\n+                        Console.WriteLine(string.Format(\"Request sent using version {0}. Successfully received response with version {1}.\", tlsRequestVersion, tlsResponseVersion));\n+\n+                        Console.WriteLine(string.Format(\"\\nResponse string: {0}.\", responseString));                        \n+                    }\n+                }\n+                \n+                // Releases the resources of the response.\n+                aadResponse.Close();\n+            }\n+            catch (Exception ex)\n+            {\n+                Console.WriteLine(\"Failed to authenticate to AAD with the exception: {0} and stack trace: {1}.\", ex.ToString(), ex.StackTrace);","path":"ServiceSamples/TLSConsoleApplication/Program.cs","position":71,"original_position":71,"commit_id":"79ab6b26f0e5873873de4551a6ebddee63b0d0d3","original_commit_id":"fac05cb374d1b16b9a158f0aeaf827888a319ffa","user":{"login":"nguhoa","id":34080196,"avatar_url":"https://avatars2.githubusercontent.com/u/34080196?v=4","gravatar_id":"","url":"https://api.github.com/users/nguhoa","html_url":"https://github.com/nguhoa","followers_url":"https://api.github.com/users/nguhoa/followers","following_url":"https://api.github.com/users/nguhoa/following{/other_user}","gists_url":"https://api.github.com/users/nguhoa/gists{/gist_id}","starred_url":"https://api.github.com/users/nguhoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguhoa/subscriptions","organizations_url":"https://api.github.com/users/nguhoa/orgs","repos_url":"https://api.github.com/users/nguhoa/repos","events_url":"https://api.github.com/users/nguhoa/events{/privacy}","received_events_url":"https://api.github.com/users/nguhoa/received_events","type":"User","site_admin":false},"body":"Authenticate to AAD is generic term. The code can fail when create the web request or when try to get response. Any of them is authentication error. What other reasons you think can happen here?","created_at":"2017-11-30T19:23:18Z","updated_at":"2017-11-30T19:23:18Z","html_url":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53#discussion_r154175450","pull_request_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/comments/154175450"},"html":{"href":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53#discussion_r154175450"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53"}},"in_reply_to_id":154169991},"pull_request":{"url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53","id":155232009,"html_url":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53","diff_url":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53.diff","patch_url":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53.patch","issue_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/53","number":53,"state":"open","locked":false,"title":"TLS authentication validation","user":{"login":"nguhoa","id":34080196,"avatar_url":"https://avatars2.githubusercontent.com/u/34080196?v=4","gravatar_id":"","url":"https://api.github.com/users/nguhoa","html_url":"https://github.com/nguhoa","followers_url":"https://api.github.com/users/nguhoa/followers","following_url":"https://api.github.com/users/nguhoa/following{/other_user}","gists_url":"https://api.github.com/users/nguhoa/gists{/gist_id}","starred_url":"https://api.github.com/users/nguhoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguhoa/subscriptions","organizations_url":"https://api.github.com/users/nguhoa/orgs","repos_url":"https://api.github.com/users/nguhoa/repos","events_url":"https://api.github.com/users/nguhoa/events{/privacy}","received_events_url":"https://api.github.com/users/nguhoa/received_events","type":"User","site_admin":false},"body":"Provide authentication validation method so user can change different type of TLS version in client configuration to test what TLS version is compatible with TLS version in D365 server.","created_at":"2017-11-29T02:04:54Z","updated_at":"2017-11-30T19:23:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"109560f0d33c3f7624631097df5ad76708b38d32","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53/commits","review_comments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53/comments","review_comment_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/53/comments","statuses_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/statuses/79ab6b26f0e5873873de4551a6ebddee63b0d0d3","head":{"label":"Microsoft:TLSAuthenticationValidation","ref":"TLSAuthenticationValidation","sha":"79ab6b26f0e5873873de4551a6ebddee63b0d0d3","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":47145958,"name":"Dynamics-AX-Integration","full_name":"Microsoft/Dynamics-AX-Integration","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/Dynamics-AX-Integration","description":"Dynamics AX Integration samples and demos.","fork":false,"url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration","forks_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/forks","keys_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/teams","hooks_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/events","assignees_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/tags","blobs_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/languages","stargazers_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/subscription","commits_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/merges","archive_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/downloads","issues_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/deployments","created_at":"2015-11-30T21:03:55Z","updated_at":"2017-11-23T13:30:03Z","pushed_at":"2017-11-30T19:03:09Z","git_url":"git://github.com/Microsoft/Dynamics-AX-Integration.git","ssh_url":"git@github.com:Microsoft/Dynamics-AX-Integration.git","clone_url":"https://github.com/Microsoft/Dynamics-AX-Integration.git","svn_url":"https://github.com/Microsoft/Dynamics-AX-Integration","homepage":null,"size":6606,"stargazers_count":74,"watchers_count":74,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"archived":false,"open_issues_count":19,"license":null,"forks":79,"open_issues":19,"watchers":74,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"cc5f4f934440edfbe3df0b57322e4ae039466d34","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":47145958,"name":"Dynamics-AX-Integration","full_name":"Microsoft/Dynamics-AX-Integration","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/Dynamics-AX-Integration","description":"Dynamics AX Integration samples and demos.","fork":false,"url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration","forks_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/forks","keys_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/teams","hooks_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/events","assignees_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/tags","blobs_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/languages","stargazers_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/subscription","commits_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/merges","archive_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/downloads","issues_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/deployments","created_at":"2015-11-30T21:03:55Z","updated_at":"2017-11-23T13:30:03Z","pushed_at":"2017-11-30T19:03:09Z","git_url":"git://github.com/Microsoft/Dynamics-AX-Integration.git","ssh_url":"git@github.com:Microsoft/Dynamics-AX-Integration.git","clone_url":"https://github.com/Microsoft/Dynamics-AX-Integration.git","svn_url":"https://github.com/Microsoft/Dynamics-AX-Integration","homepage":null,"size":6606,"stargazers_count":74,"watchers_count":74,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"archived":false,"open_issues_count":19,"license":null,"forks":79,"open_issues":19,"watchers":74,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53"},"html":{"href":"https://github.com/Microsoft/Dynamics-AX-Integration/pull/53"},"issue":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/53"},"comments":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/Dynamics-AX-Integration/statuses/79ab6b26f0e5873873de4551a6ebddee63b0d0d3"}},"author_association":"NONE"}}
{"actor":{"display_login":"nguhoa"}}