Is it possible to temporarily apply admin or last logged in user rights in order to close forms?


Author
Message
Cory Cookson
Cory Cookson
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 30, Visits: 416
Scenario:

1) User 1 logs in with admin rights and opens up form1

2) Lock Screen happens due to timeout or pushing F11

3) User 2 logs in with lower rights than User 1

4) Here I want to close form1 so that User 2 has a fresh start with no open screens.

Question:

Is there a way to temporarily provide admin or the last users rights so that open forms can be closed programatically and then return to using User 2's rights?

Cory Cookson

Software Developer

Occupational Health Research

Replies
Cory Cookson
Cory Cookson
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 30, Visits: 416
I believe that I've found a solution to the issue.  Code snippets as follows:

public static void HandleCurrentUserChanged(object sender, EventArgs e)

{

if (_UserID.Length > 0)

{

_UserChanged = (_UserID != SecurityBasics.CurrentUser.UserName.ToString());

}

_UserID = SecurityBasics.CurrentUser.UserName.ToString();

if(_UserChanged)

{

for (int i = 0; i <= Application.OpenForms.Count - 1; i++)

{

MicroFour.StrataFrame.UI.Windows.Forms.BaseForm bf = (MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)Application.OpenForms[i];

if (bf.Name != "Form1")

bf.Close();

}

}

}

private static void HandleBeforeSessionLock(object sender, EventArgs e)

{

for (int i = 0; i <= Application.OpenForms.Count - 1; i++)

{

MicroFour.StrataFrame.UI.Windows.Forms.BaseForm bf = (MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)Application.OpenForms[i];

if (bf.Name != "Form1")

{

if (bf.EditingState == MicroFour.StrataFrame.Business.BusinessEditingState.Editing)

{

if (MicroFour.StrataFrame.Messaging.MessageForm.ShowMessage("unsaved data detected",

"Do you want to save your changes to " + bf.Name, "", MicroFour.StrataFrame.Messaging.MessageFunction.YesNo, MicroFour.StrataFrame.Messaging.MessagingIcon.Question,

MicroFour.StrataFrame.Messaging.MessagingSounds.DefaultSound) == MicroFour.StrataFrame.Messaging.MessageFunctionType.Yes)

bf.Save();

else

bf.Undo();

}

}

}

}



Cory Cookson

Software Developer

Occupational Health Research

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)Strategic Support Team Member (2.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Great, Cory! Cool
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Cory Cookson - 16 Years Ago
Ivan George Borges - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Cory Cookson - 16 Years Ago
Cory Cookson - 16 Years Ago
Greg McGuffey - 16 Years Ago
Cory Cookson - 16 Years Ago
Ivan George Borges - 16 Years Ago
Cory Cookson - 16 Years Ago
Ivan George Borges - 16 Years Ago
Cory Cookson - 16 Years Ago
Cory Cookson - 16 Years Ago
     bump
Cory Cookson - 16 Years Ago
Ivan George Borges - 16 Years Ago
Dustin Taylor - 16 Years Ago
Cory Cookson - 16 Years Ago
Cory Cookson - 16 Years Ago
             Great, Cory! :cool:
Ivan George Borges - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search