【问题标题】:Example of Silverlight 5 RIA services authentication with active directory [closed]Silverlight 5 RIA 服务身份验证与活动目录的示例 [关闭]
【发布时间】:2012-02-29 13:07:58
【问题描述】:

我正在寻找具有 Active Directory 身份验证的 Silverlight 5 RIA 服务示例,

可以下载并且有效

提前致谢。

【问题讨论】:

    标签: silverlight authentication active-directory wcf-ria-services silverlight-5.0


    【解决方案1】:

    我还没有找到完整的可下载示例。最简单的方法是创建一个新的 Silverlight 业务应用程序,然后对指定的 3 个文件(Web.config、App.xaml.cs、User.cs)进行以下更改:

    App.xaml.cs

    • 注释掉(或删除)以下行:

      //webContext.Authentication = new FormsAuthentication();

    • 取消注释以下行:

      webContext.Authentication = new WindowsAuthentication();

    User.cs

    • 将 [ProfileUsage...] 语句添加到公共部分类用户,使其如下所示:

    公共部分类用户:UserBase

    {
        [ProfileUsage(IsExcluded=true)]   ///NEEDED FOR WINDOWS/ACTIVE DIRECTORY LOGON
        public string FriendlyName { get; set; }
    }
    

    Web.config:

    注释掉(或删除)以下行:

    <!--<authentication mode="Forms">
      <forms name=".AuthenticationTest_ASPXAUTH" timeout="2880" />
    </authentication>-->
    

    取消注释以下行:

    <authentication mode="Windows"/>
    

    注释掉(或删除)以下行:

        <!--<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
          <providers>
            <clear />
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </roleManager>
        <profile defaultProvider="DefaultProfileProvider">
          <properties>
            <add name="FriendlyName" />
          </properties>
          <providers>
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
          <providers>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
          <providers>
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
          </providers>
        </sessionState>-->
    
      <!--<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>-->
    
    Add the following lines:
    
      <system.serviceModel> 
        <bindings>
          <basicHttpBinding>
            <binding name="winAuthBasicHTTPBinding">
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Ntlm"/>
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="AuthenticationTest.Web.AuthenticationServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <services>
          <service behaviorConfiguration="AuthenticationTest.Web.AuthenticationServiceBehavior" name="System.Web.ApplicationServices.AuthenticationService">
            <endpoint address="" 
                      binding="basicHttpBinding" 
                      bindingConfiguration="winAuthBasicHTTPBinding" 
                      contract="System.Web.ApplicationServices.AuthenticationService">
            </endpoint>
        </service>
        </services>
      </system.serviceModel> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多