設定宣告式 Web 應用程式的表單型驗證 (SharePoint Server 2010)

 

適用版本: SharePoint Foundation 2010, SharePoint Server 2010

上次修改主題的時間: 2016-11-30

本文中的程序提供下列指導:

  • 可讓您設定 Microsoft SharePoint Server 2010 宣告式 Web 應用程式的表單型驗證。

  • 協助您升級先前設定為使用表單型驗證的現有 Office SharePoint Server 2007 Web 應用程式,搭配 SharePoint Server 2010 使用。

升級為 SharePoint Server 2010 之後,您的 Microsoft Office SharePoint Server 2007 Web 應用程式會設定為舊的登入。若是先前設定為使用 Windows 驗證的 Office SharePoint Server 2007 Web 應用程式,並不需要額外升級步驟。但是,若是先前設定為使用表單型驗證或 Web SSO 驗證的 Office SharePoint Server 2007 Web 應用程式,則必須先轉換為宣告驗證,才能在 SharePoint Server 2010.中使用 Office SharePoint Server 2007 Web 應用程式。將 Office SharePoint Server 2007 Web 應用程式轉換為宣告驗證之後,即可將 Web 應用程式區域設定為表單型驗證 (或 Web SSO 驗證,視情況而定)。最後一個步驟是將使用者及權限移轉至 SharePoint Server 2010。

本文內容:

  • 將 Web 應用程式轉換為宣告驗證

  • 使用管理中心設定表單型 Web 應用程式,以使用 LDAP 提供者

  • 設定 LDAP Web.Config 檔案

  • 使用 Windows PowerShell 設定表單型 Web 應用程式,以使用 LDAP 提供者

  • 將使用者及權限從 SharePoint Server 2007 移轉至 SharePoint Server 2010

將 Web 應用程式轉換為宣告驗證

執行下列程序中的步驟,使用 Windows PowerShell 將現有 Web 應用程式轉換為宣告驗證。

將 Web 應用程式轉換為宣告驗證

  1. 確認符合下列基本需求:請參閱<Add-SPShellAdmin>。

  2. 在 [開始] 功能表上,按一下 [所有程式]。

  3. 按一下 [Microsoft SharePoint 2010 產品]。

  4. 按一下 [SharePoint 2010 管理命令介面]。

  5. 在 Windows PowerShell 命令提示字元處,輸入下列命令:

    $w = Get-SPWebApplication "http://<server>/"
    $w.UseClaimsAuthentication = "True";
    $w.Update()
    
    $w.ProvisionGlobally()
    

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。

使用管理中心設定表單型 Web 應用程式,以使用 LDAP 提供者

執行下列程序中的步驟,使用管理中心將宣告式 Web 應用程式設定為表單型驗證。

使用管理中心將宣告式 Web 應用程式設定為表單型驗證

  1. 確認執行此程序的使用者帳戶為網站集合管理員。

  2. 在管理中心的 [應用程式管理] 下,選取 [管理 Web 應用程式]。

  3. 在功能區上,選取 [新增]。

  4. 在 [新的 Web 應用程式] 對話方塊的 [驗證] 區段中,選取 [宣告式驗證]。

  5. 在 [驗證類型] 區段中,選取 [啟用 ASP.NET 成員資格和角色提供者]。

  6. 輸入成員資格提供者名稱及角色管理員名稱。在本文所述的範例 Web.Config 檔案中,成員資格提供者的名稱為 membership,角色管理員的名稱為 rolemanager

  7. 按一下 [確定] 建立 Web 應用程式。

設定 LDAP Web.Config 檔案

成功建立 Web 應用程式 (如上述程序所述) 之後,請修改下列 Web.Config 檔案:

  • 管理中心 Web 應用程式 Web.Config 檔案

  • Security Token Service Web.Config 檔案

  • 表單型驗證宣告式 Web 應用程式 Web.Config 檔案

設定管理中心 Web.Config 檔案

  1. 在命令提示字元處輸入 INETMGR,開啟 IIS 管理員。

  2. 在 IIS 中移至 [SharePoint 管理中心] 網站。

  3. 以滑鼠右鍵按一下 [SharePoint 管理中心],然後選取 [瀏覽]。

  4. 開啟 Web.Config 檔案。

  5. 找到 <Configuration> <system.web> 區段,然後新增下列項目:

<membership defaultProvider="AspNetSqlMembershipProvider">
      <providers>
        <add name="membership" 
             type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
             server="yourserver.com" 
             port="389" 
             useSSL="false" 
             userDNAttribute="distinguishedName" 
             userNameAttribute="sAMAccountName" 
             userContainer="OU=UserAccounts,DC=internal,DC=yourcompany,DC= distinguishedName (of your userContainer)" 
             userObjectClass="person" 
             userFilter="(ObjectClass=person)" 
             scope="Subtree" 
             otherRequiredUserAttributes="sn,givenname,cn" />
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" > 
      <providers>
        <add name="roleManager" 
             type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
             server="yourserver.com" 
             port="389"
             useSSL="false"
             groupContainer="DC=internal,DC=yourcompany,DC= distinguishedName (of your groupContainer)"
             groupNameAttribute="cn"
             groupNameAlternateSearchAttribute="samAccountName"
             groupMemberAttribute="member"
             userNameAttribute="sAMAccountName"
             dnAttribute="distinguishedName"
             groupFilter="((ObjectClass=group)"
             userFilter="((ObjectClass=person)"
             scope="Subtree" />
      </providers>
 </roleManager>

重要

新增前述項目之後,儲存並關閉 Web.Config 檔案。

設定 Security Token Service Web.Config 檔案

  1. 在命令提示字元處輸入 INETMGR,開啟 IIS 管理員。

  2. 移至 [SharePoint Web 服務] 網站。

  3. 移至 [SecurityTokenServiceAppliction] 子網站。

  4. 以滑鼠右鍵按一下 [SharePoint 管理中心],然後選取 [瀏覽]。

  5. 開啟 Web.Config 檔案。

  6. 找到 <Configuration> <system.web> 區段,然後新增下列項目:

<membership>
      <providers>
        <add name="membership" 
             type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
             server="yourserver.com" 
             port="389" 
             useSSL="false" 
             userDNAttribute="distinguishedName" 
             userNameAttribute="sAMAccountName" 
             userContainer="OU=UserAccounts,DC=internal,DC=yourcompany,DC=com" 
             userObjectClass="person" 
             userFilter="(&amp;(ObjectClass=person))" 
             scope="Subtree" 
             otherRequiredUserAttributes="sn,givenname,cn" />
      </providers>
    </membership>
    <roleManager enabled="true" > 
      <providers>
        <add name="rolemanager" 
             type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
             server="yourserver.com" 
             port="389"
             useSSL="false"
             groupContainer="DC=internal,DC=yourcompany,DC=com"
             groupNameAttribute="cn"
             groupNameAlternateSearchAttribute="samAccountName"
             groupMemberAttribute="member"
             userNameAttribute="sAMAccountName"
             dnAttribute="distinguishedName"
             groupFilter="(&amp;(ObjectClass=group))"
             userFilter="(&amp;(ObjectClass=person))"
             scope="Subtree" />
      </providers>
    </roleManager>

重要

新增前述項目之後,儲存並關閉 Web.Config 檔案。

設定表單型驗證宣告式 Web 應用程式 Web.Config 檔案

  1. 在命令提示字元處輸入 INETMGR,開啟 IIS 管理員。

  2. 移至 [宣告表單] 網站。

  3. 以滑鼠右鍵按一下 [宣告表單],然後選取 [瀏覽]。

  4. 開啟 Web.Config 檔案。

  5. 找到 <Configuration> <system.web> 區段。

  6. 找到 <membership defaultProvider="i"> 區段,然後新增下列項目:

<add name="membership" 
             type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
             server="yourserver.com" 
             port="389" 
             useSSL="false" 
             userDNAttribute="distinguishedName" 
             userNameAttribute="sAMAccountName" 
             userContainer="OU=UserAccounts,DC=internal, DC=yourcompany,DC=com" 
             userObjectClass="person" 
             userFilter="(&amp;(ObjectClass=person))" 
             scope="Subtree" 
             otherRequiredUserAttributes="sn,givenname,cn" />

找到 <roleManager defaultProvider="c" enabled="true" cacheRolesInCookie="false"> 區段,然後新增下列項目:

<add name="roleManager" 
             type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
             server="yourserver.com" 
             port="389"
             useSSL="false"
             groupContainer="DC=internal,DC=yourcompany,DC=com"
             groupNameAttribute="cn"
             groupNameAlternateSearchAttribute="samAccountName"
             groupMemberAttribute="member"
             userNameAttribute="sAMAccountName"
             dnAttribute="distinguishedName"
             groupFilter="(&amp;(ObjectClass=group))"
             userFilter="(&amp;(ObjectClass=person))"
             scope="Subtree" />

重要

新增前述項目之後,儲存並關閉 Web.Config 檔案。

警告

請勿覆寫此 Web.Config 檔案中的任何現有項目。

使用 Windows PowerShell 設定表單型 Web 應用程式,以使用 LDAP 提供者

執行下列程序中的步驟,使用 Windows PowerShell 將宣告式 Web 應用程式設定為表單型驗證。

使用 Windows PowerShell 設定表單型 Web 應用程式,以使用 LDAP 提供者

  1. 確認符合下列基本需求:請參閱<Add-SPShellAdmin>。

  2. 在 [開始] 功能表上,按一下 [所有程式]。

  3. 按一下 [Microsoft SharePoint 2010 產品]。

  4. 按一下 [SharePoint 2010 管理命令介面]。

  5. 在 Windows PowerShell 命令提示字元處,輸入下列命令:

    $ap = New-SPAuthenticationProvider -Name "ClaimsForms" -ASPNETMembershipProvider "membership" -ASPNETRoleProviderName "rolemanager"
    $wa = New-SPWebApplication -Name "Claims Windows Web App" -ApplicationPool "Claims App Pool" -ApplicationPoolAccount "internal\appool"
      -Url https://servername -Port 80 -AuthenticationProvider $ap
    

    注意

    ApplicationPoolAccount 參數值必須為伺服器陣列上的受管理帳戶。

  6. 成功建立驗證提供者及 Web 應用程式之後,請使用本文<設定 LDAP Web.Config 檔案>一節中的範例項目,修改下列 Web.Config 檔案:

    • 管理中心 Web 應用程式 Web.Config 檔案

    • Security Token Service Web.Config 檔案

    • 表單型驗證宣告式 Web 應用程式 Web.Config 檔案

  7. 修改 Web.Config 檔案之後,請建立 SPClaimsPrinciple 及網站集合,如下列範例所示:

    $cp = New-SPClaimsPrincipal -Identity "membership:SiteOwner" -IdentityType FormsUser
    $sp = New-SPSite http://servername:port -OwnerAlias $cp.Encode() -Template "STS#0"
    

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。

將使用者及權限從 SharePoint Server 2007 移轉至 SharePoint Server 2010

執行下列程序中的步驟,使用 Windows PowerShell 移轉使用者及權限。

將使用者及權限從 SharePoint Server 2007 移轉至 SharePoint Server 2010

  1. 確認符合下列基本需求:請參閱<Add-SPShellAdmin>。

  2. 在 [開始] 功能表上,按一下 [所有程式]。

  3. 按一下 [Microsoft SharePoint 2010 產品]。

  4. 按一下 [SharePoint 2010 管理命令介面]。

  5. 在 Windows PowerShell 命令提示字元處,輸入下列命令:

    $w = Get-SPWebApplication "http://<server>/"
    $w.MigrateUsers(True)
    

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。