﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Role Based Security  » Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 14:06:21 GMT</lastBuildDate><ttl>20</ttl><item><title>Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13988.aspx</link><description>All I want to do is simply make something invisible...a navigation group on a DevExpress Navigation Bar Control.&amp;nbsp; Here is my attempt after setting up roles and permissions, then DDT to deploy:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;if&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SecurityBasics&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.CurrentUser.GetPermission(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"SystemMaintenance"&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;).Action == &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PermissionAction&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;.Grant)&lt;BR&gt;&lt;/FONT&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AdminNavBarGroup.Visible = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AdminNavBarGroup.Visible = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;I have a role called "Administration".&amp;nbsp; A permission key was created for a category called Administration (not technically related).&amp;nbsp; The key is use above and it is called "SystemMaintenance".&amp;nbsp; The key is given grant rights for the "Administration" role.&amp;nbsp; I removed myself from that role to test.&amp;nbsp; The only thing that may be gumming&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;up the works is the fact that my profile is marked as an administrator.&amp;nbsp; Does the administrator bypass any and all permission sets?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;What would be nice is SecurityBasics.CurrentUser.IsInRole("Administration").&amp;nbsp; It would simply return a boolean value.&amp;nbsp; It look like I have to create a dictionary list then walk the list to see if the user is in the role or not.&amp;nbsp; Is that right?&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Thanks for your help,&lt;BR&gt;Bill&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 06 Feb 2008 09:41:38 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14075.aspx</link><description>Any time Bill. It takes a while to really understand RBS, as it is pretty complex/full featured. It rocks though!  :D</description><pubDate>Wed, 06 Feb 2008 09:41:38 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14051.aspx</link><description>You got it...this is the same approach that we take and we have good roles and data setup so that our customers can implement their desired security permissions easily.&amp;nbsp; But it is definitely best NOT to grant by default. :)</description><pubDate>Tue, 05 Feb 2008 16:31:11 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14050.aspx</link><description>Well, if I do this:&lt;/P&gt;&lt;FONT color=#2b91af size=2&gt;&lt;P&gt;SecurityBasics&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.DefaultPermissionInfo = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PermissionInfo&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PermissionAction&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;.Grant);&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;Then, I have&amp;nbsp;to specifically deny people access to everything they should not have access to (the taking-away-the-keys-to-the-kingdom approach).&amp;nbsp; I see more why Greg suggested deny as the default (the don't-let-them-have-the-keys-at-all approach).&amp;nbsp;&amp;nbsp;This will take a bit of time to setup.&amp;nbsp; I see why you suggest waiting until the end of&amp;nbsp;the development process; however, I may have been better served to consider&amp;nbsp;some of this stuff up-front.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help, gents!&lt;BR&gt;Bill&amp;nbsp;</description><pubDate>Tue, 05 Feb 2008 16:21:40 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14039.aspx</link><description>Yup.&amp;nbsp; That seems to work.&amp;nbsp; I am getting ready to test the change, now.&amp;nbsp; Should know something soon.</description><pubDate>Tue, 05 Feb 2008 14:29:21 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14036.aspx</link><description>Set it on the SecurityBasics shared property:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;MicroFour.StrataFrame.Security.SecurityBasics.DefaultPermissionInfo = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Security.PermissionInfo(MicroFour.StrataFrame.Security.PermissionAction.Grant)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]</description><pubDate>Tue, 05 Feb 2008 14:07:30 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14035.aspx</link><description>[quote][b]Greg McGuffey (02/04/2008)[/b][hr]...make sure that the SecurityBasics.DefaultPermissionInfo and DefaultPermissionAction are set to Deny.[/quote]&lt;/P&gt;&lt;P&gt;The Action on DefaultPermissionInfo is Read-Only.&amp;nbsp; I cannot set that in the InitApplication method of program.cs.&amp;nbsp; Do you have syntax handy to show me how to set this?&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR&gt;Bill</description><pubDate>Tue, 05 Feb 2008 14:05:39 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost14005.aspx</link><description>Good answers, Greg. :)</description><pubDate>Tue, 05 Feb 2008 09:56:24 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13995.aspx</link><description>Thanks a bunch, Greg!&amp;nbsp; I'll work through these debugging tips tomorrow afternoon when I get back to the office.&amp;nbsp; Talk to you then!&lt;/P&gt;&lt;P&gt;Bill</description><pubDate>Mon, 04 Feb 2008 20:26:55 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13994.aspx</link><description>The code you posted should enable the [b]AdminNavBarGroup[/b] when the user has Grant action for the [b]SystemMaintenance[/b] permission.  If it isn't then something else is going on. The first thing I'd do is put a break point on the if statement and make sure I know who the user is and if they have that permission, using the watch &amp;#119;indow.  The next thing I'd do is make sure that the [b]AdminNavBarGroup[/b].Visible property is set correctly.  This will tell you if you do in fact have the user setup correctly, e.g. a user without the [b]SystemMaintenance[/b] permission set to something other than Grant.  If your user is setup such that they don't have that permission assigned at all, then check out the InitApplication shared application event handler in AppMain (or whatever the C# equivalent is) and make sure that the SecurityBasics.DefaultPermissionInfo and DefaultPermissionAction are set to Deny.  This is used when a user doesn't have the permission explicitly defined.&lt;br&gt;
&lt;br&gt;
If the permission is fine and the visible is getting set correctly, then the next step is to figure out what else might be messing with the Visible property.  Some other code that is putting back to visible.&lt;br&gt;
&lt;br&gt;
These ideas come to mind because...well...I've done them before.  :blush:</description><pubDate>Mon, 04 Feb 2008 19:56:10 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13992.aspx</link><description>Nope.&amp;nbsp; The code failed.&amp;nbsp; The non-admin user was still able to access the group.&amp;nbsp; Not good.&amp;nbsp; How do I simply check if a user is in a specific role or not?&amp;nbsp; Maybe that is the better question.&amp;nbsp; I really don't see that in the docs.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR&gt;Bill</description><pubDate>Mon, 04 Feb 2008 17:07:45 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13991.aspx</link><description>Sooooo...my code above works, just not for those lively admins.&amp;nbsp; The response will always be true for them.&amp;nbsp; Got it.&amp;nbsp; I'll see if I can test this elsewhere to determine accessibility.&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR&gt;Bill</description><pubDate>Mon, 04 Feb 2008 16:58:35 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Is there a comparable method like SecurityBasics.CurrentUser.IsInRole("NameOfRole")?</title><link>http://forum.strataframe.net/FindPost13990.aspx</link><description>If I understand you, you are logged in as a user that is a SF administrator (either the admin user setup in the initialize method in AppMain or a user who is marked as an administrator) and that user doesn't have some desired permission, yet is always passing this test?&lt;br&gt;
&lt;br&gt;
This is correct. Users with SF admin status are automatically granted access to all permissions.  The permission isn't even checked if they are an admin, it just returns true.  &lt;br&gt;
&lt;br&gt;
Sounds like a nice request (IsInRole), but I wonder about complications, such as what if the user has Deny on that role, vs. Grant?  You might be better off to just check if the user is an admin:&lt;br&gt;
&lt;br&gt;
[codesnippet]if (SecurityBasics.CurrentUser.GetPermission("SystemMaintenance").Action == PermissionAction.Grant &amp;&amp; !SecurityBasics.CurrentUser.IsAdministator)&lt;br&gt;
{&lt;br&gt;
    AdminNavBarGroup.Visible = true;&lt;br&gt;
}&lt;br&gt;
else&lt;br&gt;
{&lt;br&gt;
    AdminNavBarGroup.Visible = false;&lt;br&gt;
}[/codesnippet]</description><pubDate>Mon, 04 Feb 2008 16:24:21 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>