2013-08-26 2 views
1

URL http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx에 제공된 프로세스를 사용하여 활성 디렉토리 인증을 성공적으로 구현했습니다. 여기서 우리는 https://login.microsoftonline.com/에서 사용자를 인증하고 웹 사이트로 돌아갈 수 있지만 인증 후에는 액세스 토큰을 얻을 수 없습니다. 인증을 거친 후 사용자 이름, 성 등을 액세스 할 수 있지만 액세스 토큰은 액세스 할 수없는 코드를 따라야합니다. 인증 후 액세스 토큰을 얻을 수있는 코드를 제공해 줄 수 있습니까? 또한 설정 파일에 saveBootstrapContext 속성을 설정해야합니다windows Azure Active Directory 인증 후 액세스 토큰을 얻는 방법

ClaimsPrincipal cp = ClaimsPrincipal.Current; 
ClaimsIdentity ci = cp.Identity as ClaimsIdentity; 
BootstrapContext bc = ci.BootstrapContext as BootstrapContext; 
SecurityToken securityToken = bc.SecurityToken; 

:

public class HomeController : Controller 
    { 
     public ActionResult Index() 
     { 

      ClaimsPrincipal cp = ClaimsPrincipal.Current; 
      string fullname = 
        string.Format("{0} {1}", cp.FindFirst(ClaimTypes.GivenName).Value, 
        cp.FindFirst(ClaimTypes.Surname).Value); 
      ViewBag.Message = string.Format("Dear {0}, welcome to the Expense Note App", 
           fullname);        

      return View(); 

     } 
} 
+0

무엇 토큰으로하고 싶니? WIF 인프라는 토큰의 유효성 검사와 토큰의 생성을 담당합니다. – Chandermani

+0

api를 호출 할 때이 토큰이 필요합니다. 이 토큰은 매개 변수로 전달됩니다. – Abhishek

답변

2

당신은 사용 된 보안 토큰에 액세스하려면이 코드를 사용할 수 있습니다

<system.identityModel> 
    <identityConfiguration saveBootstrapContext="true"> 
    ... 
</system.identityModel> 
관련 문제