views:

39

answers:

1

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.

+1  A: 

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

Einarsson
Yes I am extending Authentication base and the GetOperations method is part of the extended class - why can't I see it?
Calanus
Did you set WebContext.Current.Authentication To your authenticationservice ?If using Unitycontainer:Container.RegisterInstance(Of AuthenticationService)(WebContext.Current.Authentication)
Einarsson
And we access the Login method through new AuthenticationService().Login() so you should be able to access your methods that way. Not through WebContext.Current.
Einarsson
I did set the WebContext.Current.Authentication to my authentication service. I can see the Login method, I just can't see any "new" methods. Even if I do var x = new AuthenticationContext(); x.GetOperations(y,z); it claims that GetOperations doesn't exist!
Calanus
Dang, youre right. Only login is available. But when you call login while overriding ValidateUser, you will eventually get there. Can you do your logic from there?Else, it seems like you will have to make another domain service to handle different things than just authentication.Maybe the authenticationbase is just for handling login/logout/isloggedin etc. And then you'll have to have a useraccountservice or something that handles the roles etc. :)
Einarsson
sigh I think that you are right - I will use another domain service to do get the operations for the role. I still wish that I understood why I can't see the new methods in the service though - there is something that I am not understanding here....
Calanus