.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Best Practices for elevating permissions in a Win Forms Application

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Windows Application


Here is the situation.  I am working to create a windows forms application which allows various help desk personnel to view active directory and powercampus (a sql db) data for users.  The program must also be able to reset users passwords.  It will be installed on multiple desktop machines on our network.

This requires a certain level of permissions which we do not want to give to the Active Directory accounts of the personnel who will use it.

My working solution in this case is to create an Active Directory account for the application, give that account the necessary permissions and then have the application impersonate this account when it needs elevated permissions.  I'm using advapi32.dll-LogonUser.  The username and password for the account are hard coded into the program.

My question is, how do i do this better?  Is there some other way to give the application elevated permissions without giving those permissions to the users.  Is there a better way to impersonate an active directory account.  Last, i know that hard coding the username and password is not very secure.  I would prefer to encrypt the information somehow, but then the program must have the key to decrypt, which is only 1 step removed from what i have now.  how can i safely and simply encrypt the account password?


View Complete Post

More Related Resource Links

Application Architecture in Windows Forms 2.0

Applications have special support in Windows Forms. For starters, you can manage and tailor your application's lifetime, and, when the work flow is disrupted by an unhandled exception, you can choose from several methods of response. Then, there are several application models that you can employ, including Single Document Interface (SDI) and Multiple Document Interface (MDI) applications, each of which can support either multiple-instance or single-instance mode, the former the VS05 default and the latter requiring special consideration. All applications, however, can discover and use a wide variety of information about the system and environment they execute in.

Application Architecture in Windows Forms 2.0-Single-MDI Applications

Consider an MDI application like Microsoft Excel; files opened from the file system (by double-clicking) are all opened as separate child windows within the parent Excel window.7 For the first instance of an MDI application to open a new child window to display the file that was passed to the second instance of the application, the second instance must be able to communicate with the initial instance.

Required permissions cannot be acquired when host asp.net 3.5 application in godaddy


I got the following error when click print report button.

Application : asp.net 3.5

Crystal report : 10.5

Host: godaddy

Please help me.


Required permissions cannot be acquired.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Digital Signatures: Application Guidelines on Digital Signature Practices for Common Criteria Securi


This article is an overview of digital signature practices and user considerations necessary to write applications in compliance with ISO/IEC 15408 Common Criteria security. Signing categories are described, including those that are a potential risk to the implied trust association that goes with a digital signature.

Jack Davis

MSDN Magazine November 2009

.NET Internals: Tailor Your Application by Building a Custom Forms Designer with .NET


The design-time architecture of Windows Forms in the .NET Framework has made development much more flexible than it had been with MFC. With Windows Forms, you can drag one of your custom controls from the toolbox and drop it onto the Visual Studio design surface and even though Windows Forms knows nothing about the control, it's able to host it and let you manipulate its properties-not possible in MFC. In this article, the author discusses what's going on under the covers as you design your forms and then walks through the creation of a bare-bones forms designer.

Sayed Y. Hashimi

MSDN Magazine December 2004

Windows Forms: Give Your .NET-based Application a Fast and Responsive UI with Multiple Threads


If your application performs any non-UI processing on the thread that controls the user interface, it may make the app seem slow and sluggish, frustrating users. But writing multithreaded apps for Windows has long been restricted to C++ developers. Now with the .NET Framework, you can take advantage of multiple threads in C# to control the flow of instructions in your programs and isolate the UI thread for a fast and snappy user interface. This article shows you how. Also, it discusses the pitfalls of multiple threads and presents a framework for safe concurrent thread execution.

Ian Griffiths

MSDN Magazine February 2003

Forms Based Authentication on Extranet Application

I have a web application that is using classic authentication. I have extended it to my extranet so I can use https from the outside. All of this works, except I would like to have the extranet users not have to type domain\username. I am guessing I need to use claims based authentication with forms. It seems the only way to do this, would be to go back in time, and tell my original application to use claims based instead of windows. Is there a way I could have just my extended site use forms? I would really like to keep my extranet users out of active directory, as they are not part of my company.

How to add Sharepoint dll reference to Windows Forms application project in Visual Studio 2010?

Hi,I am using Windows Forms application template in Visual Studio 2010 Beta. I created this for some R & D work. Now I am using Sharepoint object model in application. When I am trying to add Sharepoint dll reference from .NET tab, I can not see Windows Sharepoint Services there Which was available in Visual Studio 2005.Also If I am add this sharepoint dll from ISAPI folder (14 Hive), it is added succesfully, but it is not taking actually in project and showing me an error during running mode that theError 12 The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) Please suggest me how to add Sharepoint dll reference in Windows forms application in Visual Studio 2010?

Windows Forms application Stopped Working message in Windows Vista



A Windows Forms application developed with VB2008 Express that has been successfully run on two Windows XP systems and a Windows 7 system fails to run on two of two Windows Vista systems tried so far.


Attempting to run the app on a Windows Vista system results in a system dialog box titled, Microsoft Windows, with the message, A problem caused the program to stop working correctly.  Windows will close the program and notify you if a solution is available.  A single button at the lower right of the dialog contains the text, Close Program.
The initial form of the application never displayed and the dialog above appeared with little delay after attempting to start the program.

The program uses an SQL Server Compact Edition 3.5 database and the program is compiled to include the following .DLL files so the user does not need to install SQL ServerCE.

The Load event of the initial form causes a DataSet to be filled from the SQL CE DB.

I have the System Informa

I need a dynamic connection string for my windows forms application.


Hello folks


I am brand new to forms applications and visual studio 2008 I am building a forms application to connect to a 3rd party's sdf file. There is no password or username required to connect however the 3rd party app installs the sdf in the users folder for me I am on windows 7 but I have clients on xp.


I went to add a data connection and chose sql ce file and browsed out to my location and it connects and works. But I need this connection string to be for whoever is logged into there laptops or computers no matter the operating system version xp,vista,7.


Data Source=C:\User\username\AppData\Roaming\PS\GES\surve.sdf


Can someone tell me how to do that. Also please explain in words a new borne could understand cause like I said I am new to this.


Thank you


ListBox in Forms application



In my forms application, I want to use a ListBox.
For example:

string name = TextBox1.Text;
string address = TextBox2.Text;
string city = listBox1.SelectedValue.ToString();

I have added several options to the listbox but when I start / debug the program and I select an option in the listbox, it doesn't work. I think I miss something here.

What's the right way to use a ListBox in my form ?



Reporting Services Forms Authentication and group permissions


Hello all,

I have spent some time getting Forms Authentication working with 2008 (R2) I have one final problem left that is causing intense frustration...

The working bits:

a) Built and tested the required extension - thanks to a combination of old Microsoft example supplemented by the one from chapter 19 of Teo Lachev's book, supplemented by Brian Lawson's book.

b) used existing user/group structures in the db to implement role level permissions

c) Can now grant rights to usernames and the usernames validated against our db, they can log in fine and run reports.

d) Nice customised login screens that login across the application and Reporting Services with a single login - which was the primary aim after all!

e) can grant rights to folders at group level and granting/revoking those rights adds or removes the folders in ReportManager - all looking wonderful

The last hurdle:

If I grant permissions to a specific username (we use email address as the username) then that user can log in to ReportManager fine and see what they should see, so it seems like the bulk of the authentication and authorisation extension logic is OK.

If I grant the exact same permission to a role, and make a login a member of that role (removing the specific username permission) then they

How to make the windows forms application install only 1 time and be used only 1 time only



I have a need to create an applicaiton that can be installed 1 time only be a user. The application can also be used only 1 time. (on a given PC)

The user may or may not be and administrator.

How can I do this (without registry alteration if possible)?

Thanks much.


expense claim application - how to set up item level permissions on expense claim document set


Hi All,

I want to create an app that replaces the existing paper-form based expenses reimbursement process with a SharePoint solution.

I have created a content type called an Expense Form Set ( it includes an excel sheet for the user to enter expenses and also includes any digitised receipts associated with the claim )

The claimant can create an expense form set in an Expense claims document library and the Expense Claims Approver is notified, they approve or reject and reimburse if necessary.

however there is a stumbling block.

How do we prevent anyone else other than the person who submitted the claim and the person who needs to approve/reject from seeing the expense claim.

Is turning on content approval the only way to do this.

If so then the act of approving the content will make it visible to anyone else who has view or contribute access to the library.

thanks and regards,


SQL Server 2005 random login failures for windows forms application


One of our VS .NET 2008 windows forms applications runs from multiple client machines. The application randomly has login failures from random machines and from random places in the code. The login works almost every time but about once every fifteen minutes an error shows up in SQL Server error logs from a random user. We are running a clustered SQL Server 2005 system and the database is in 2005 (90) mode.

The following error appears in the SQL Server error logs:

Login failed for 'App_Login'. [CLIENT: XXX.XXX.X.XXX] Error: 18456, Severity: 14, State: 16.

The following error is what the client sees:

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend