Developer forum

Forum » Development » Getting details about a current backend user

Getting details about a current backend user


Reply

Hi.


How to I get the details about the user currently logged into the backend.


Let's say I have logged on with a user with limited acces to various areas and modules. Now when this user edits a module in the modules-list I need to distinguish to which area the user is linked to present the right features.


 


All the information I need is located under the Table AccessUser column :AccessUserModules I just lack the information about the current user to cross-reference ID or name.


 


/H.   


 


 


Replies

 
Nicolai Høeg Pedersen
Reply

You can get information on the current user doing like this:


 


Session("DW_Admin_Login") holds True or false if the user is logged on or not


 


To get detailed information on the user currently logged on: 


Dim usr As Backend.User


usr = Session("DW_Admin_User")


  


 


The Backend.User object will give you the details, like username, userid etc.


  


To check for permissions, you can do like this:


 


'To check if a user has access to a surden module:


If Base.HasAccess("News", "") Then


 


End If


 


'To check if a user has access to a surden Category in a module:


If Base.HasAccess("NewsCategories", drNews("NewsCategoryID")) Then


 


End If


 


To get the second option to work you need to specify some information in module table of Database Dynamic.mdb. You have to specify ModuleDatabase, ModuleTable, ModuleFieldID and ModuleFieldName with some database information. After you do this, the usermodule gives you the possibility to control access to different categories/areas of a module.


 


Note: The first variable in has access is either the systemname (checking for general access) or the systemname postfixed with "Categories" when checking for a surden category/area.

 
Reply
NP wrote:


You can get information on the current user doing like this:




 




Session("DW_Admin_Login") holds True or false if the user is logged on or not




 




To get detailed information on the user currently logged on: 




Dim usr As Backend.User




usr = Session("DW_Admin_User")




  




 




The Backend.User object will give you the details, like username, userid etc.




  




To check for permissions, you can do like this:




 




'To check if a user has access to a surden module:




If Base.HasAccess("News", "") Then




 




End If




 




'To check if a user has access to a surden Category in a module:




If Base.HasAccess("NewsCategories", drNews("NewsCategoryID")) Then




 




End If




 




To get the second option to work you need to specify some information in module table of Database Dynamic.mdb. You have to specify ModuleDatabase, ModuleTable, ModuleFieldID and ModuleFieldName with some database information. After you do this, the usermodule gives you the possibility to control access to different categories/areas of a module.




 




Note: The first variable in has access is either the systemname (checking for general access) or the systemname postfixed with "Categories" when checking for a surden category/area.






Thank you for the information. Just want I needed, but is there no way arounds using session variables? Let's say a newer version with different session-names comes out, maintaining code with session variables will then become very difficult.


You could for instance implement a static method or property in Dynamicweb.Backend, Dynamicweb.Admin or Dynamicweb.Access called "currentUser" which denotes an AccessUser object containing the needed properties.


 


/H.




 
Nicolai Høeg Pedersen
Reply

At the moment its not possible. But you are right.


 


We are in the middle of a process of making Dynamicweb a little more slick when it comes to that.

 

You must be logged in to post in the forum