Set Form Based on CurrentUser/Role
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Set Form Based on CurrentUser/RoleExpand / Collapse
Author
Message
Posted 03/01/2008 10:36:12 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/17/2008 2:36:51 PM
Posts: 367, Visits: 1,295
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

Post #14637
Posted 03/01/2008 1:25:32 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: Yesterday @ 5:34:42 AM
Posts: 16, Visits: 2,351
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

Post #14638
Posted 03/03/2008 8:35:43 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 2 days ago @ 9:53:39 AM
Posts: 2,654, Visits: 1,869
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.


www.bungie.net
Post #14642
Posted 03/03/2008 12:48:12 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/17/2008 2:36:51 PM
Posts: 367, Visits: 1,295
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

Post #14645
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 12:13am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.