Search code examples
apidashboardsyncfusion

Query User logged in with Dashboard Platform


I'm utilizing syncfusion's api to changeConnectiongString. I have a switch statement that'll drive what the connection string is to be changed to but I'm having trouble querying who is logged in so I can't utilize the api.

May I ask has anyone queried used syncfusion's dashboard api and were able to successfully query who is logged in. If so may I get some tips or pointers.


Solution

  • You can refer the below code snippet that helps to bring the currently logged in user information.

    (HttpContext.Current.User as Syncfusion.Server.Base.ServerPrincipal)
    

    Hence, User name can be obtained throguh,

    (HttpContext.Current.User as Syncfusion.Server.Base.ServerPrincipal).UserName
    

    and email of the corresponding user can be obtained through,

    (HttpContext.Current.User as Syncfusion.Server.Base.ServerPrincipal).UserEmail