Application Settings scope - user vs application - vb.net

If I create a user level application setting and bind it to a text box on a form, then type something in the textbox, the value is automatically saved and when the application is launched again the value appears in the textbox. This doesn't happen when I scope the setting as application.
Why are application scoped settings not saved automatically like user scoped settings are?
If this is by design, how can I manually save these settings and load them at runtime?

In short, application scoped settings can't be changed at runtime while user scoped settings are designed be read/written at runtime. There are a number of alternatives to using application scoped settings:
Use user scoped settings
This post recommends looking into the ConfigurationManager class.
If you don't like user scoped settings because they are not written to the application directory you can implementing your own SettingsProvider and have them written where ever you'd like
This post has some recommendations on how to best manage settings. Finally, here is Microsoft's documentation on the settings architecture if you're interested in extending theirs or rolling your own.

Related

Setting properties (like date format, time format etc.) for a worklight app from another worklight app in same project

Can I set some properties for a worklight app from another worklight app, in the same project ?
I want to make one configuration app which configures properties, like date format/time format/enabling-disabling some functionalities etc, for different worklight applications in the same project.
Is that possible?
You could probably achieve this, but there is nothing built-in or existing that does this.
Whatever you do will have to go through the Worklight Server and not peer-to-peer.
Here's what you could possibly do (you'll need to actually implement it and see how feasible it is):
Note that this is highly simplified; it's just general steps.
User application
Application launches
User logs-in
Upon successful log-in, invoke some "RemoteControl" adapter procedure, "applySettings".
By default this will return a pre-defined configuration, a set of application settings that the client logic will know how to apply. Like some JSON object containing key:value pairs that you will apply logic based on them.
Since all client applications will connect to the Worklight Server, they are thus registered in the database with the user identity.
Controller application
In the Controller application, you will be able to retrieve a list of all registered users as well as retrieve the settings that are set for each of the listed users, using the "RemoteControl" adapter procedure "retrieveRegisteredUsersAndSettings".
Devise some UI for all users and the available settings and checkboxes etc which will be marked with whichever settings are enabled or disabled per user.
Have another procedure in the same "RemoteControl" adapter, "setSettings". This will store the user settings in the database
When the user logs-in, these same set settings from step 6 are applied instead of the previous default (now changed...) settings in step 3.
Notes:
You could also have it so the procedure will be invoked whenever doing any sort of request to the server rather than only after log-in. Purely applicative.
If you have more than 1 application, you could also save in the database using userPrefs which app the logged-in user uses and the retrieve this information as well in the controller application; you can then sort the display of all of this information in the UI.

Dynamic Roles/Hierarchy with SimpleMembership

I finally got my MVC 4 application all set up with SimpleMembership, but now have run into a new problem. I have a menu system (in a sidebar) that gives users access to various functionality throughout the app. I recently realized that, in order to be somewhat user-friendly, I need to disable or remove various menu links based on roles. So I set up a role system and a relationship to these menu links, which works perfectly. However, the "basic site access" role should not have access to all of the links in the menu (and their corresponding controllers/actions). Previously, I had given site access by simply applying the Authorize attribute globally, via my filter config:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new AuthorizeAttribute());
}
Now I've figured out that, in order to control "basic" access to the app, I would need to add individual Authorize attributes at the action level (with the "admin" role having full access). While this is fine, albeit somewhat annoying, it doesn't seem very scalable. What if my client adds a new role through the administration interface and wants to control access to various tasks? I have already coded the menu system to disable links dynamically, based on what roles have access to which tasks. But there's no way (that I know of) to dynamically apply different roles to the Authorize attribute.
Though I've read about why SimpleMembership may not be the bee's knees, I've just finished migrating from ASP.NET Membership (which had serious shortcomings of its own), and I certainly do not want to roll my own user/role management system. Has anyone successfully implemented something to handle this scenario?
You should definitely take a look at Fluent Security if you have a lot of controllers/actions that you don't want to decorate with annotations.
It allows all authorisation to be handled from Global.asax. It's well documented and there's a good tutorial on it here.

User specific setting in rails

I am developing a Ruby on Rails application. In my app I have a setting on the welcome page where user can select the language (by default is English). Where should I declare this variable and where should I change it from default once the user changes it?
I tried declaring a config variable in development.rb, but since it is global for the applicaition, if user A changes the language, user B will also see the changes done by user A.
I need a setting which is user specific. In other words: one session specific. When I open the website it should initialize to the default and when I change it, the application should not apply those changes to others.
If you "need a setting which is user specific" you could define a session variable:
session[:language]

Play Framework User Authentication/Membership

I want to support user authentication in a Play Application. It is Web App and I think that the built-in "Secure" module is too simple for my needs. In fact, the user group discusses how the Secure module is really for demonstration purproses. However, how can I develop such a system?
Essentially, the application will allow the user to login and then they will have their own settings and so forth applied throughout the application. There are some pages for which unauthenticated users can view but if the client is authenticated, then the view of those pages will be different. Pretty simple setup but most documentation just refers to the simple Secure module.
If your only special requirement is that some pages be publicly visible, I've got your answer: Play framework: How to require login for some actions, but not all . I just copied the Secure module and made a few small additions.
You can use the PlayPlugins for this. I started to write a plugin which enabled Security in powerful way. It's an migration from BasisSecurity for Grails. At the moment I don't find the time to further development. You can see the current state here https://code.launchpad.net/~opensource21/+junk/permsec.
from your requirements the current authentication module seems enough. If not, what I did for my project was:
Copy the classes from the module (Secure controller, the annotation, the tag) to your project
Extend the controller adding additional functionalities
I don't have my code handy to put samples here, but in general I:
renamed the classes (so apologies if I say one name meaning another, don't remember the original names!)
added methods in Secure Controller to handle OpenId and OAUth authentication
added support methods in my User model that given the Id of a service (Google OpenId, Twitter id, etc) returns an existing user from the DB with that ID, or if it doesn't exists creates and returns a new user linked to that id.
added some flags (like admin, supervisor, etc) to User class
modified the check method in security controller so it checks the values of the annotation with the flags of the user. Something like (pseudocode)
var ok : Boolean = false
ok = ok || (annotation.value == "admin" && currentUser.isadmin)
ok = ok || (annotation.value == "supervisor" && currentUser.issupervisor)
...
added the annotation to the corresponding methods, and added the Secure controller (via #With) tot he classes that require access check
With this I have a secured system, and it seems to work quite well (fingers crossed :P)
Don't know if it could help you but look at the deadbolt module to manage access rights to views/controllers...
http://www.playframework.org/modules/deadbolt-1.0/home

How to store current user information, security, and preferences

I need a Global variable/class that stores some basic information about the currently logged in user including that user's preferences, security rights, UserID, etc. This information will be needed by any/every part of my application.
In the past I have either used a Public variable/class in a vb.net module for this purpose. I'm trying to get away from my old ways of doing things and was curious what people currently do for this functionality.
I am thinking a singleton or 2 regarding preferences and security but am not sure if that is the best way to go.
EDIT: This is an n-Tier WinForms application.
In my ASP .net web app, I store an object that contains login information for that user in the Session Cache. That is one way.
If you want different "global variables" for each user, then sessions are the way to go (as Russell mentioned). If you want variables that are the same for every single user, then Application variables are what you want.