Secure Menu Items Based on User - winforms

On this winform application I am writing, I want to secure one menu item from most users. It runs a month-end and cannot be easily backed out if accidentally run. The menu option opens up a window to prompt the user for some information before processing. I don't care where exactly I do the check, but I want to be sure only certain users can run this function.
A Google search (on my question title above) didn't turn up anything obvious. Can anyone point me in a direction to pick up who is signed into Windows and how to check if they are authorized?

This page has some code for getting user details and checking them.
This code:
public string GetloggedinUserName()
{
System.Security.Principal.WindowsIdentity currentUser =
System.Security.Principal.WindowsIdentity.GetCurrent();
return currentUser.Name;
}
returns the current user name. You could use this to check against your list of authorised users.
More details on the WindowsIdentityclass can be found here.
It has a Groups property which you could use to check for membership of a group rather than having to check individual users.

Related

Only 2 steps are different when compared to two feature files. (cucumber-selenium-java)

I am learning cucumber. I have two scenarios. I can't say the exact due to company policies. First Step file is like
Scenario 1: Flow with attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And attaches "files"
And Go to location page
And add comments
Then Submit
Scenario2: Flow without attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And add players manually
And User picks players
And User clicks on a player
And does the settings
And Go to location page
And add comments
Then Submit
Do I need to write all the steps again in Scenario 2 or can I do something so that I can bypass writing all the steps in feature file.
I mean can I maintain only different steps in the 2nd feature while like we do in writing step file or glue code for that.
If yes how to do it, so that it run all the previous steps. Please help
Instead of writing all the steps in terms of small actions the users performs on the system (like "go to page", "click this" , "submit that"), think about what the user is trying to achieve and create a step that describes that in a way that is meaningful to the user (i.e. "add players from a file", or "add players manually"). The step definition for that step will then contain all of these actions on the system (click this, fill that, etc). You can also use what we call "helper methods" from your step definition; for example create a method that will navigate to a certain page, and call that method with the relevant page to go to from your various step definitions.
That way your scenarios will describe the intended behaviour of the system, or what the user is supposed to be allowed to do (or not do).
Also, from the examples you've provided it is not clear to me what it is you are testing/asserting. I've always found it helpful to use "Given/And" to set up the original state of the system, "When/And" for the actions to be performed that you want to test the outcome of, and "Then/And" to verify the expected result.
The title of the scenario should clearly describe what it is the scenario tests for.
From your example, I've assumed that you are testing that a user is able to add players either from a file or manually. In that case, the scenarios could look something like the following:
Scenario: User is able to add players from a file
Given a user who is logged in
And the user has selected "country"
When the user attaches "files"
And adds a comment about location
Then the players are added
And the comment is saved
Scenario: user is able to add players manually
Given a user who is logged in
And the user has selected "country"
When the user adds players manually
And adds a comment about location
Then the players are added
And the comment is saved
In the example above, I am also assuming that the following steps:
And add players manually
And User picks players
And User clicks on a player
And does the settings
are actually all (always) needed to add players manually, so all of those actions would be performed in the one step "And add players manually" (either by implementing them all in one step, or calling several helper methods from that one step).
By describing the behaviour like this it is much clearer what you are testing in each scenario and what the expected behaviour of the system is.
Also, it will lead to way less duplication of "steps" (as was your original question, I believe).

How to show ICredentialProviderCredentialv2 on more than one User tile on the other user tile

I'm trying to develop a Credentialprovider v2. I'm experimenting around with the samplecredentialproviderv2 provided by Microsoft.After installing the redistributable 2013 and compiling for the right architecture, I'd registered it and it worked.
My Problem is, it works only on the first shown user tile. If I enumerate more than one usertile, it is either shown in only one user tile, or I became an error and destroyed my Logon UI.
I know the question is quite similar to this one. Here I can say I've tried the solution stated in the mentioned Microsoft document. There is a function which indicates if the "other user" tile is shown and this function works quite good. The only thing is, the else if won't work, because if you get a legit tile getSid won't reach the else if. So if you return in getSid a null sid and hr_false the credentialprovider is shown the other user tile, but in this case not shown everywhere else. If this solution is hard coded.
I've tried to create more than one ICredentialProviderCredential, so that I have a list of interfaces, but it doesn't worked.
The document, which is provided here, says the following:
"• v2 credential providers must implement the ICredentialProviderCredential2 interface and return a valid SID on the GetUserSID function. This tells Windows which user(s) the provider should be associated with."
My problem is, how to return more than one Sid in the GetUserSid function.
It would be great if you can help.
In ICredentialProvider::GetCredentialCount() you return the number of credential tiles (one per user) that your credential provider will supply (the credential provider can learn how many users there 'are' from the user array given to SetUserArray() ). Return a different ICredentialProviderCredential2 instance in response to each call logon makes to your ICredentialProvider::GetCredentialAt(), and from each of these instances return a different SID in response to GetUserSID(). Each of your credentials should then be associated with a different user at logon.

Salesforce field level access determined by third variable

For the contacts object, I have a custom checkbox which represents whether the contact owner wants the contact information (email and phone) to be visible. Most of our contacts will be completely visible to everyone. However, for a few contacts, we want them to be visible but their contact information needs to be hidden to everyone except for the owner.
Is there a way to set field-level access dependent on another variable? Could you create a workflow to redirect to another page layout if the contact information is visible? If so, can you restrict objects to certain field layouts depending on whether or not you are the record owner? And would would the contact information for "hidden contacts" still show up in reports?
Redirects, custom Visualforce view page etc hacks are all nice and shiny until you realize people will be able to pull data they want via some reports, list views, Outlook integration, mobile apps etc ;)
There's no straightforward answer because field visibility is really "all or nothing" (by Profiles & Permission Sets). Owner/Role-related stuff will help you only if you'd store data in some new related objects.
Another option - Store public part in Leads (public read only for example) and sensitive part - in Contacts (private)? Some lookup to link the 2, maybe a trigger when new Contact is created and you're good to go.
Last but not least - have a look at https://salesforce.stackexchange.com/questions/777/can-i-grant-different-field-level-security-based-on-record-ownership for some ideas.
If I understood correctly (My english...) You could create a new RecordType and a new customized page layout without this fields assigned to it, then you have to create a WFR that change the Recordtype when the cheked field becomes true.
I'm assuming that you know how you have to give permissions to this new Recordtype...etc
Hope this helps.

Website "you can do this" script

I want to create a training path for new users accessing my site. This training path must display info bubbles showing what you can do on every page, but only the first time you access it.
So, for example, if a user enters a page where there's an edit button an info box should appear next to the edit button telling the user that he can edit that page.
I will create the script myself, I just want to know what's the best method to check if the user has already seen that box or not. I was thinking about storing in database a boolean value for each info box which will be set to true if the user has seen the box. To save some queries from the DB I think I can also store the same values in localStorage or in Cookies.
What is the best practice for creating user training paths for a website?
The way I suggest is to store user id (ip or username ? ) and a bit value for each bubble like you say.
PS: for your script you can use this:
http://www.maxvergelli.com/jquery-bubble-popup/documentation/
Jérôme

Best way to populate a dropdown sitewide that is

I am using CakePHP 1.3 and a layout which includes a dropdown of organizations a user has access to administer, so I'm trying to populate that dropdown with organizations that contain the userid that is logged in, but I want to populate it before the user sees anything so they can use it in the header. The dropdown needs to appear on every page once logged in. I tried adding the query to pull these organizations in the appcontroller, but userid was not yet available to use in before filter. Where or how should I do this? Should it be in session or is there a better construct to use? Element?
In my app it's no problem to use the user_id from within the beforeRender (if you are using the Auth-Component).
You can use it with $this->Auth->user('id').
I would do it like this: Check in the AppController if the user is logged in. If he is, pull your wanted information from the database (or whereever you get your information from) and store it in a variable called $dropdown for example.
If the user is not logged in, $dropdown will be false.
You now make this variable available to the view with $this->set(compact('dropdown'))
Now in your layout (this is important to you have it on every page) you can easily do a check if $dropdown is false or not. If not, you can work with your variable and show the user your wanted dropdown.

Resources