This project has moved. For the latest updates, please go here.

[en] Log on to the server (solved)

Topics: Technical Support
Aug 2, 2013 at 10:29 AM
youdontcay wrote:

I have used
credentials.Add (AuthRequestMessage.CREDENTIAL_USERNAME, LoginViewModel.Account);
credentials.Add (AuthRequestMessage.CREDENTIAL_PASSWORD, LoginViewModel.Password);
credentials.Add (AuthRequestMessage.CREDENTIAL_DOMAIN, "ITJH");
credentials.Add (AuthRequestMessage.CREDENTIAL_WINDOWS_SECURITY_TOKEN, "1");
Log on to the server.
And realized IAuthenticationProvider through the database user password authentication users.
I want to ask me how to get the current logged-in user service side.
Like the Server.User property as convenient.
Aug 2, 2013 at 10:40 AM
Please use ServerSession.CurrentSession property:
// get server-side identity of the current client
var currentUser = ServerSession.CurrentSession.Identity;
Make sure that your implementation of IAuthenticationProvider returns the proper AuthenticatedIdentity:
// in your authentication provider code:
public AuthResponseMessage Authenticate()
    // load the user data from the database and create user identity object
    // ...
    var identity = new MyIdentityClass(userName);

    // then return
    return new AuthResponseMessage()
        ErrorMessage = string.Empty,
        Success = true,
        AuthenticatedIdentity = identity
For the custom IAuthenticationProvider, you'll also need to provide your implementation of IIdentity interface.
It's very easy to do, here is an example:
public class MyIdentityClass : IIdentity
    public MyIdentityClass(string name)
        Name = name;

    public string AuthenticationType
       get { return "Default"; }

    public bool IsAuthenticated
       get { return true; }

    public string Name { get; private set; }
Marked as answer by yallie on 10/18/2013 at 4:06 AM
Aug 3, 2013 at 1:01 AM
Thank you, the problem has been solved