开发者

Silveright - extending AuthenticationService to provide custom authentication

开发者 https://www.devze.com 2023-01-06 18:27 出处:网络
I am trying to add to the authentication system provided in the Silverlight 4 business template as my model does not completely fit that provided in the template. I have an existing web service that p

I am trying to add to the authentication system provided in the Silverlight 4 business template as my model does not completely fit that provided in the template. I have an existing web service that performs my authentication and provides roles and also permitted operations for each role. This is the model provided by AzMan/Authentication Manager.

However, rather than just get a single role, following authentication开发者_开发技巧 I provide the user with a list of available roles and allow the user to select one of these roles and then get a list of operations/actions for that selected role.

The problem that I have is that I can't work out how to add new methods to the authenticationservice to allow me to get the operations for the current user, and currently selected role in order to complete the login process e.g.

    public SessionInfo GetOperations(string username, string selectedRole)
    {
        SessionInfo sessionInfo;

        using (AzManServiceClient azClient = new AzManServiceClient("AnonymousAuthentication"))
        {
            sessionInfo = azClient.LoginUserByUsername("msldap://CN=LiveApps,CN=Program Data,DC=HLSUK,DC=local", "AIRS", selectedRole, null, username);
        }

        return sessionInfo;
    }

The above method is not accessible from the LoginForm.xaml.cs using WebContextBase.Current.Authentication... Only methods such as Login are visible which is even more baffling because I can't see these methods in authenticationbase. I'm completely confused. How do I add new methods to the authentication service, or should I create a new domainservice, or should I access the azman service to get the operations directly from the silverlight client.


Have you tried to Override the methods in AuthenticationBase?

Then you can expand your authenticationservice with whatever logic you want.

 <EnableClientAccess()>
        Public Class AuthenticationRiaService
            Inherits AuthenticationBase(Of UserAccount)

            Protected Overrides Function ValidateUser(ByVal userName As String, ByVal password As String) As Boolean
            End Function
    End Class

Also set

WebContext.Current.Authentication To your authenticationservice as found in namespace System.ServiceModel.DomainServices.Client.ApplicationServices

Sorry for stupid VB code. :D

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号