2012-01-01 14 views
2

表單身份驗證不起作用。當SMF嘗試訪問需要特定用戶角色的服務器上的* .ism/Manifest文件時,Auth cookie不會發送到服務器。Microsoft媒體平臺+表單身份驗證

我該怎麼做: 1.使用支持RIA WCF創建新的Silverlight Smooth Streaming模板。 2.配置的web.config:

<connectionStrings> 
<add name="ApplicationServices" connectionString="Data Source=[SERVER];Initial Catalog=[CATALOG];User ID=[USER];Pwd=[PASSWORD];" providerName="System.Data.SqlClient" /> 

<system.web> 
     <authentication mode="Forms"> 
     <forms loginUrl="~/Account/LogOn" timeout="2880" /> 
     </authentication> 
     <membership> 
     <providers> 
      <clear /> 
      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> 
     </providers> 
     </membership> 
     <profile> 
     <providers> 
      <clear /> 
      <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
     </providers> 
     <properties> 
      <add name="Gender" /> 
      <add name="Birthday" /> 
      <add name="AvatarPath" /> 
     </properties> 
     </profile> 
     <roleManager enabled="true"> 
     <providers> 
      <clear /> 
      <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" /> 
      <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" /> 
     </providers> 
     </roleManager> 
  1. 添加身份認證服務和正確的用戶類(添加3個道具)。
  2. 在客戶端添加這app.xaml.cs:
 public App() 
    { 
    //Default things... 
    InitializeWebContext(); 
    } 

    private void InitializeWebContext() 
    { 
     WebContext webContext = new WebContext(); 
     var fa = new FormsAuthentication(); 
     var ac = new AuthenticationDomainService1(); 
     fa.DomainContext = ac; 
     fa.Login(new LoginParameters("user", "password"), (y) => 
                    { 
                     if (!y.HasError) 
                     { 
                      this.RootVisual = new MainPage(); 
                     } 
                    }, null); 
     webContext.Authentication = fa; 
     ApplicationLifetimeObjects.Add(webContext); 
     Resources.Add("WebContext", WebContext.Current); 
    } 

的訪問是由web.config文件在目標目錄限制:在這個角色

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
     <system.web> 
      <authorization> 
      <allow roles="Role_name" />  
      <deny users="*" />          
      </authorization> 
     </system.web> 
    </configuration> 

用戶存在。

當我使用Xaml(Big Bunny)中指定的默認視頻時 - 一切都很好。但是,當我將媒體源更改爲我的服務器上受限區域的路徑時,出現訪問錯誤。 在客戶端,我成功獲取用戶憑證。

提琴手顯示下一件事: 當我嘗試訪問的WCF RIA另一個resctricted方法([RequiresAuthentication]),客戶端發送驗證的cookie,但是當SMFPlayer嘗試訪問媒體源,該cookie發送wasn`t。

我錯過了什麼?

回答

0

我找到了一些解決方法: 如果您將流文件傳輸到子目錄並限制對其的訪問(而不是具有「ism」文件的目錄)。清單將發佈給匿名用戶,但數據流僅用於註冊(當玩家嘗試觸摸數據流時,它會成功附加auth cookie)。