2012-05-14 39 views
0

在Sharepoint 2010中,我們創建了一個具有經典身份驗證的Web應用程序,並開始開發它。後來,我們希望對我們的項目實施表單身份驗證,因此我創建了一個啓用了基於表單的身份驗證的新SharePoint Web應用程序。我把舊網站的備份(經典認證)並恢復到新網站(fba)。我實現了表單認證通過跟隨下面的鏈接:表單身份驗證問題 - 驗證後無法從登錄頁面重定向到主頁

Configuring Forms Based Authentication for SharePoint 2010 using IIS7

我創建了一個自定義的登錄頁面。輸入有效憑證後,用戶不會重定向到主頁。身份驗證正常發生,但不會重定向到主頁。當我點擊登錄按鈕時,它將再次加載相同的登錄頁面。請找到以下代碼進行驗證並重定向到主頁:

protected void btnLogin2_Click(object sender, EventArgs e) 
{ 
    if (Membership.ValidateUser(txtUserId.Value, txtPassword.Value)) 
    { 
    string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx"); 

    Response.Redirect(link); 

    //I tried with the below line also but it is of no use 
    // SPUtility.Redirect(link, SPRedirectFlags.Default, this.Context); 
    } 
    else 
    { 
    lblMessage.Text = "Login Failed."; 
    } 
} 

我們無法找出問題所在。我嘗試了這麼多的解決方案,但他們沒用。

回答

2

請使用SPClaimsUtility對基於聲明的應用程序中的用戶授權。

從添加Microsoft.SharePoint.IdentityModel DLL參考。\組件\ GAC_MSIL \ Microsoft.SharePoint.IdentityModel \ 14.0.0.0__71e9bce111e9429c \ Microsoft.SharePoint.IdentityModel.dll訪問SPClaimsUtility

比試試這個:

SPSecurity.RunWithElevatedPrivileges(delegate() 
     { 
      bool status = SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, txtUserId.Value, txtPassword.Value); 
      if (status) 
       { 
       string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx"; 
       Response.Redirect(link); 
       } 
     }); 
+0

謝謝你的快速回答。我用你的代碼。我試圖以管理員/用戶身份登錄,但它拋出了「訪問被拒絕」錯誤。我錯過了什麼嗎?請幫助我。 –

+0

可能你必須爲那些你想登錄的用戶提供權限,以及哪一行出現錯誤? – Jigs

+0

看看這個鏈接:http://stackoverflow.com/questions/7778223/sharepoint-claims-based-authentication-new-user-use-case跳過它的幫助。 – Jigs

相關問題