我正在寻找带有活动目录身份验证的Silverlight 5 RIA服务的示例,
可以下载并运行
提前致谢。
答案 0 :(得分:3)
我还没有找到完整的可下载示例。最简单的方法是创建一个新的Silverlight业务应用程序,然后对指定的3个文件(Web.config,App.xaml.cs,User.cs)进行以下更改:
<强> App.xaml.cs 强>
注释掉(或删除)以下行:
// webContext.Authentication = new FormsAuthentication();
取消注释以下行:
webContext.Authentication = new WindowsAuthentication();
<强> User.cs 强>
public partial class User: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>