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

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

Securely Saving Windows Auto Logon Password in .NET

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :.NET Framework

I'm trying to securely store a password for autologon in Windows through .NET.  There are lots of examples out there about how to securely store the password in C++ or about how to *insecurely* store the password in .NET.  But I can't find any examples that do it securely in .NET.

Here's the article that explains how to do this insecurely:

And in it there's a link to how to do it securely using C++:

View Complete Post

More Related Resource Links

how do i create a windows form application login for to validate username and password from sql serv

 I would like to know how I can create a login form for my windows form application. The login form must be linked to a SQL server 2005 express edition database (in which the username and passwords are stored). The login form must validate the user using the database and allow them to access the program. 

Auto saving the Winform application

hi,   I am developing a huge win form application, which has lot of win forms, user controls and wizards. For user it will take some time to fill-in all the fields and complete the wizard. I wanted to implement auto saving the application for every 3-4 minutes, this should be done in the background without disturbing the user activity (or thread)..   can anyone help me to implement this? Please share your ideas.   thanks

LDAP - directory entry issue with out user and password using impersonate and windows authentication

Hi All I am using the below code to fetch the user information from LDAP             DirectoryEntry entry = new DirectoryEntry("LDAP://DEV");             DirectorySearcher searcher =  new DirectorySearcher(entry);             SearchResult result;             searcher.Filter = "samaccountname=testuser";             result = searcher.FindOne(); here i am using windows authentication always and along with that when i enable the impersonate = true ,  the code fails at "result = searcher.FindOne();" with message "object reference not set to instance of an object "  also with the same code if i give the username and password along with the impersonate tag >> it works  or if i am using the user and password along with the DirectoryEntry  object then also it will work  but it fails with same user that i gave in impersonate tag / directory entry object with windows authentication enabled  and the  user logged to the application and no username and password tag in directory entry / impersonate tag  Interesting thing is that  in our development server ,  i am able to execute the same code with out user name p

How to auto set forms width automatically on different versions of windows OS.

How to auto set forms width automatically on different versions of windows OS.My application running on Windows Server 2000 Pops a new windows forms side by side the MDI and fits without overlapping.  When the same application is hosted on Windows Server 2008 and the new window pops up, it is overlapping on the existing MDI.

Windows 7, Office 2007, and WSS 3.0: Losing file path when saving to Document Library.

A client of ours recently purchased 5 desktops with Windows 7 and Office 2007.  They use Sharepoint to share all documents for their company. The computers that have Windows XP on them can browse the Sharepoint site, open documents (read only or edit), and chose to Save or Save As.  A new window pops open with their current file path of the Sharepoint Document Library so they can save the file in the same folder they opened it from.  I have tested this with Office 2003 and 2007 (Word and Excel) on XP and it always works. The 5 new desktops running Windows 7 cannot do this.  When a user opens a document by browsing to it from Internet Explorer and chooses to Save or Save As, they are kicked back to their last successful save point (usually My Documents or Desktop). The current work around is mapping a drive to the root Document Library directory and having them traverse through the folders to save it back in the original location. I've tried changing the Check Out save settings in Word 2007 and Excel 2007 to edit directly on the server, but I run into the same problem.  I've also made sure that IE sees the site as a Local Intranet site and Protected Mode is off. Any help would be appreciated.  Thanks in advance.

Auto-generating Name When Saving an Image

hi guys, I have a toolbar on my chart:  <Toolbar Enabled="True"> <Items> <dcwc:CommandUIItem CommandName="PrintPreview" /> <dcwc:CommandUIItem CommandName="Print" /> <dcwc:CommandUIItem CommandName="Separator"/> <dcwc:CommandUIItem CommandName="SaveImage" /> <dcwc:CommandUIItem CommandName="Separator" /> <dcwc:CommandUIItem CommandName="UserDefined_1" /> </Items> </Toolbar>     For the SaveImage, I want to be able to set my image name with its own name. the name can be found using:   string fileName = Request.PhysicalApplicationPath + @"graphs\"+User.Identity.Name+graphID+".jpg"; Right now, when I click save, it always show chart.png And also, I want to download the chart as jpg.   thanks guys.

Change windows password remotely


Hi all,

Not sure where to post this, so I thought I'd start here...

I am designing a website (ASP.NET in VB) and I'd like it to have the following features: to generate a random string to be used as a password. This bit I should be able to manage, the bit I don't have a clue on is how I can pass this to a Windows machine (on a workgroup not AD) to change a user's account password.

In summary, can anyone help me to remotely change a user's password on a Windows workgroup machine using ASP.NET with VB?

FYI, I have full administrator access.

Thanks in advance for any help you can provide.
Jim :-)

How to connect to a WCF intalled as a windows service with user name and password


I have installed my WCF service using

        <endpoint address="service" binding="wsDualHttpBinding" contract="aa.IABC" name="HttpBinding"/>

And I intall this service as a Windows service..

When installing the service I am giving

                serviceProcessInstaller1.Account = ServiceAccount.User;
                serviceProcessInstaller1.Username = userName;
                serviceProcessInstaller1.Password = password;   

I am trying to connect to this service using my client but cannot open the channel .


          <binding name="HttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
              receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"

Saving a Windows form variables ?




I wonder if there is a built-in clever way to save (and to be able to reload) all the variables from a Windows form into a file (maybe an .xml).

I'm talking about all the values contained in the elements such avec textboxes, checkboxes, comboboxes, datagrids?, etc ...


Thank you

Change Password for Windows Authentication


Hello all,

I do not seem to be able to find even a yes no answer on this...

Using windows Authentication... is it possible to progrematically change a password?


I tried using several ways to do this. I tried using the ChangePassword  control. This tells me that minimun characters is 7 even though I have more then 7 characters... I also tried using this method:

            if (u.ChangePassword(TextBox2.Text, TextBox3.Text))
                LabelError.Text = "Password changed.";
                LabelError.Text = "Password change failed. Please re-enter your values and try again.";
        catch (Exception ex)
            LabelError.Text = "An exception occurred: " + Server.HtmlEncode(ex.Message) + "<BE>" + ex.ToString() + ". Please re-enter your values and try again.";


The user is always null... and I am assuming this is because this object is indended to use with Forms authentication.


All I want to do is have an option for users to change passwords. Is this possible with Windows Authentication?

Using Logon Form with Windows Authentication


I have created an Intranet site using windows authentication based on role membership.  It is working great.  My Web.config is shown below.

  <authentication mode="Windows" />
  <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />
   <allow roles="D820\Developers, D820\IT, D820\Staff, D820\Providers, D820\Supervisors, D820\Directors, D820\Interns" />
      <deny users="?"/>

Now my user wants the capability of being able to login to the intranet site as another user.  For example, IT guy needs to login on a user's system to set some data.

I have created a standard MS Login Page.  However when I try to login on the page I get the message

Your login attempt was not successful. Please try again

I do not have a database (aspnetdb.mdf) storing user information but login against the active directory.  Can you use the login form with windows authentication without a database?

If yes, can you point me to an article that describes how to do it?

Thanks for your he

How to reset Windows 7/Vista/XP/2000 password if you forgot or lost windows password


It is truly very often for us to meet the password problem, sometimes we would forgot windows password or lost windows password, and could not login windows system and make a big trouble. At this time, you would hope to find a way to reset and recover the forgotten password.
Actually, a lot of methods are available to recover or reset the Windows password. But most of them are designed for PC experts, not common PC users, those solutions are too complicated to get it work for us. And in this article, I will show you a professional software tool which could help you to reset forgotten windows password easily.

Total Windows Password Reset is powerful password recovery software to reset Windows admin
passwords for you to login Windows OS without reinstalling the OS when you forgot windows password or lost windows password. It could remove windows password and set the password to blank. Just boot from the program CD/DVD or USB flash drive, choose the account you wish to reset and all will be done. It is not a method to crack or bypass windows password, just remove or delete windows password and set it to blank so you could login windows to set new password.
Below is the guide of how to reset windows password with this software, only 3 steps are needed to reset windows 7/Vista/XP password:

Step 1: Download the setup file of Total Windows Password

How to hide SQL Server password from user in an Windows Forms Application?


Using - VS 2005, SQL Server 2005 Express, Windows Forms Application


I am unable to find a way that hides the password to connect to database in case of a Windws Forms Application.

- app.config is accessible to the user, so connection strings an be read.

- app.config can't be encrypted as in case of ASP.NET applications

- hardcoding the password in the application in connectionstring still makes it possible to be discovered by a user

Vibhor Agarwal

Auto populated 'New item form' not saving to sql

Hi, I have created a 'New item form' for a sql datasource via Sharepoint Designer. A lot of the fields are pre-populated using parameters pulled from a wedpart on the same aspx page. I have assigned the parameter to the field by setting the 'text' value to equal the parameter e.g. text="{$p3address3}". If I manually type values into the form (with no pre-populated at all) the data saves perfectly into the sql table but if I submit the form when I have pre-populated the fields then no data saves at all. Am I missing something? Is there a different way to set the values for my fields? Thanks Jeni

Resetting user Password and setting User Must Change Password at next Logon with ASPX


Hi All,

I am having an issue with an asp.net project that I am doing and have been struggling with it for a while now and was hoping someone here might be able to help me out.

Basically what we are doing is resetting peoples passwords via a web page. I have got it to the point that it is resetting the users password but is not setting User Must Change Password at Next Logon in AD. Just so that I can save you time asking the lstOffice.Text in the Connection String is so that our Admin can select the office that the users profile is present in on the AD. 

The code is shown below (connection strings and users/passwords have been changed):

 Sub SetPassword()

        Dim de As New DirectoryEntry("LDAP://IP:389/ou=Layer1" + ", " + "ou =" + lstOffice.Text + ", " + "ou=Layer3,DC=1,DC=2,DC=com,DC=au")
        'authent for AD 
        de.AuthenticationType = AuthenticationTypes.Secure
        de.Username = "ADMIN"
        de.Password = "NotTh3realpassword"

            ' new directory searcher
            Dim ds As New DirectorySearcher(de)

            Dim mySearchResultColl As SearchResultCollection

            Dim mySearchResult As SearchResult
            '  ds.Filter = ("sAMAccountname = " + name)

old and new password valid at the next logon



I have a domain controller on windows 2008 server R2, The users are able to modify their password through a web page. Once it's done, the users are still able tu use the old password as well as the new one at the next logon. The old password is still active only one time after the change, after that it's no more possible to use it...

I invoke the "ChangePassword" function.

Any Idea ? Is it a parameter to configure on the server ? Is it cached somewhere on the computer of the users ?

Thank you in advance

Here is my code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.DirectoryServices;
using System.Diagnostics;
using System.Text;
using System.Web.Security;
using System.Text.RegularExpressions;
using System.Web.Configuration;
using System.Net.Mail;
//using ActiveDs;

/// <summary>
/// Summary description for Ldap
/// </summary>
public class Ldap
	public Ldap()

    protected DirectoryEntry connectToLDap(String domain, String userName, String password)
        DirectoryEntry de=null;
            de = new DirectoryEntry("LDAP://" + domain);
            de.Username = userName;
            de.Password = password;
            de.AuthenticationType = AuthenticationTy
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