{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/2659","repository_url":"https://api.github.com/repos/IdentityServer/IdentityServer3","labels_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/2659/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/2659/comments","events_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/2659/events","html_url":"https://github.com/IdentityServer/IdentityServer3/issues/2659","id":138188138,"number":2659,"title":"Null context.Subject.Claims in Custom AD UserService GetProfileAsync","user":{"login":"pashute","id":1774131,"avatar_url":"https://avatars.githubusercontent.com/u/1774131?v=3","gravatar_id":"","url":"https://api.github.com/users/pashute","html_url":"https://github.com/pashute","followers_url":"https://api.github.com/users/pashute/followers","following_url":"https://api.github.com/users/pashute/following{/other_user}","gists_url":"https://api.github.com/users/pashute/gists{/gist_id}","starred_url":"https://api.github.com/users/pashute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pashute/subscriptions","organizations_url":"https://api.github.com/users/pashute/orgs","repos_url":"https://api.github.com/users/pashute/repos","events_url":"https://api.github.com/users/pashute/events{/privacy}","received_events_url":"https://api.github.com/users/pashute/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-03T14:11:13Z","updated_at":"2016-03-03T14:12:28Z","closed_at":null,"body":"- [v] I read and understood how to enable [logging](https://identityserver.github.io/Documentation/docsv2/configuration/logging.html)\r\n\r\n### Question\r\nIdentityServer3 and ActiveDirectory GetProfileAsync() failure: \r\n\r\nIn the AuthenticateLocalAsync() I successfully validate the user/pw against the AD. \r\nI then can access the AD groups via a \r\n\r\n```\r\nusing (PrincipalContext pc =\r\n                            new PrincipalContext(ContextType.Domain, domain, username, pw))\r\n```\r\n\r\nAnd create a list of claims, one \"role\" claim for each of the groups the user was found in. \r\n\r\nBefore returning from AuthenticateLocalAsync I set the context: \r\n\r\n```\r\n                    context.AuthenticateResult = new AuthenticateResult(\r\n                                                        subject: domainAndName, // format: 'domain\\name'\r\n                                                        name: username,\r\n                                                        claims: claims);                   // list of claims found\r\n\r\n                    return Task.FromResult(0);\r\n\r\n```\r\n\r\nAll runs OK. I find 12 \"role\" claims. The code me logs me in, on the IdentityServer.\r\n\r\nHowever when I am entered into the `GetProfileDataAsync`, although the context data has the context.Subject ok, with my name and subjectID as set above, the claims are null. \r\n\r\n\r\n```\r\nvar claims = context.Subject.Claims as List<Claim>\r\n\r\n```\r\n\r\nSince I do not have the password anymore at this stage, I cannot access the AD and get the groups of the user. \r\n\r\nIs there any way that I can set the profile claims during the AuthenticateLocal when I have the password available, or is there some other way I should be achieving this?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/comments/191778737","html_url":"https://github.com/IdentityServer/IdentityServer3/issues/2659#issuecomment-191778737","issue_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/2659","id":191778737,"user":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T14:12:28Z","updated_at":"2016-03-03T14:12:28Z","body":"as List<Claims> might be the wrong cast. Is `context.Subject.Claims` null?"}}