Saturday, October 6, 2012

Example of Silverlight 5 RIA services authentication with active directory

Example of Silverlight 5 RIA services authentication with active directory

I'm looking for example of Silverlight 5 RIA services with authentication with active directory,

that can be downloaded and that works

Thanks in advance.

Answers & Comments...

Answer: 1

I have not found a complete downloadable example. The easiest way is to create a new Silverlight Business Application and then make the following changes to the 3 files specified (Web.config, App.xaml.cs, User.cs):

App.xaml.cs

  • Comment out (or remove) the following lines:

    //webContext.Authentication = new FormsAuthentication();

  • Uncomment the following lines:

    webContext.Authentication = new WindowsAuthentication();

User.cs

  • add the [ProfileUsage...] statement to the public partial class user so it looks like the following:

public partial class User : UserBase

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

Web.config:

Comment out (or remove) the following lines:

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

Uncomment the following lines:

<authentication mode="Windows"/> 

Comment out (or remove) the following lines:

    <!--<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>  
by : Rob Williamshttp://stackoverflow.com/users/1723914




1 comment:

Anonymous said...

My brother recommended I might like this blog. He was
totally right. This post truly made my day. You cann't imagine just how much time I had spent for this info! Thanks!

Feel free to surf to my weblog: term paper outline template

Post a Comment

Send us your comment related to the topic mentioned on the blog