Set Form Based on CurrentUser/Role


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Teddy and Ben,

Thanks!  The UserName from the System.Environment namespace is exactly what I needed.  I am setting the SF Current User to the AD User, so they are the same after authentication is settled.

Have a good day!
Bill

StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Teddy is right about the currently logged in Windows user, and if that's what you're looking for the, that will take care of it. 

If you're looking for the current logged in StrataFrame user, you can get access to the username through the MicroFour.StrataFrame.Security.SecurityBasics.CurrentUser.Username property.  However, the ShowGateway gets called before the ShowLoginAndInitMainForm, so you will want to just move your code that shows the login form to the ShowGateway just like you would have it in the ShowLoginAndInitMainForm method.

Teddy Jensen
Teddy Jensen
StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 8K
Hi Bill,

In your own example instead of System.Environment.MachineName i am pretty sure you can do System.Environment.UserName, which  returns the logged on user on the machine.

Then you can extend your users table (or create a new table with additional userinfo and link it to the users table)  with info on which form to load on startup.

Then you should be able to read the user, query your field with forminfo for that user and show the returned form.

/Teddy


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)StrataFrame VIP (1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
In order to do what I wanted to do I utilized the ShowGateway() method in the program.cs.  I added two forms to the collection in InitApplication.  Then I added the following code to the ShowGateway method:

if (System.Environment.MachineName != "COMPNAME")
{
    e.FormIndexToShow = 0;
}
else
{
    e.FormIndexToShow = 1;
}

This does work.  My actual code involves a little more string manipulation in order to limit the number of workstations to three that get FormIndex 1; however, if I logged on to those workstations as myself (an admin), it would be nice to get the general window (index 0).  That won't happen, though.  Only the one form will be displayed. 

So, here is my question:  how do I set the main form based on the current logged in user name or a role assigned to that user?

Thanks,
Bill


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search