2013-03-04 58 views
1

我使用的是Window Azure平臺爲我的應用程序,我試着從他們在谷歌/雅虎帳戶提取用戶的信息..如何添加自定義聲明到ACS服務標識

但信息米通過Azure的輸入/輸出索賠獲取只是他們的名字,電子郵件地址和身份提供者...有人可以幫助我獲取他們的國家或他們的移動號碼,當他們已經在谷歌/雅虎註冊

這是我的示例代碼獲取聲稱:

protected void Page_Load(object sender, EventArgs e) 
    { 
     { 
      ClaimsPrincipal icp = Thread.CurrentPrincipal as ClaimsPrincipal; 
      ClaimsIdentity claimsidentity = icp.Identity as ClaimsIdentity; 
      string email = "", name = "", idprovider = "" ; 
      foreach (Claim c in claimsidentity.Claims) 
      { 

       if (c.ClaimType == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress") 
       { 
        email = c.Value; 
       } 
       if (c.ClaimType == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name") 
       { 
        name = c.Value; 
       } 
       if (c.ClaimType == "http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider") 
       { 
        idprovider = c.Value; 
       } 

      } 

      Label1.Text = (name + email + idprovider); 

當m編輯我的規則時,ClaimsPrincipal不會將country/mobilenumber的值計入其帳戶中.... PLZ HELP !!!!!

回答

2

據我所知 - 並非直接,這就是它應該是!

當用戶同意向您的應用程序提供他或她的身份時,他們並不一定明確同意與您分享個人資料信息,因此身份提供者不應該那樣做。

在我看來,一些提供商已經提供了太多 - 我不希望他們分享任何東西,但一個GUID,就像微軟一樣。谷歌例如分享名稱以及電子郵件地址,我不一定要允許。很多時候我都會傾向於保留我的gmail電子郵件地址的私密性,併爲我登錄的應用程序提供另一種或完全不同的電子郵件地址。

簡而言之 - 如果你想獲得關於你的用戶的任何信息 - 你應該問他們,而不是從其他地方得到它。

更多關於這個觀點,如果有興趣,在這裏 - http://yossidahan.wordpress.com/2012/02/19/end-to-end-authentication-and-authorisation-scenario-for-mvcacs/

相關問題