Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

DefaultPassword (advapi32)
 
.
Summary
If you enable autologon, it is more convenient to use Windows; however this feature may pose a security risk. If you set a computer for autologon, anyone who can physically obtain access to the computer can gain access to all of the computer contents, including any network or networks it is connected to. In addition, when autologon is enabled, the password is stored in the registry in plaintext. The specific registry key that stores this value is remotely readable by the Authenticated Users group. This setting is only recommended for cases where the computer is physically secured, and steps have been taken to ensure that untrusted users cannot remotely access the registry.

A more secure way is to store the AutoLogon password in LSA using LsaStorePrivateData with DefaultPassword as KeyName and the password as PrivateData

A more secure way is to store the AutoLogon password in LSA using LsaStorePrivateData

C# Signature:

[DllImport("advapi32.dll", SetLastError = true, PreserveSig = true)]

    private static extern uint LsaStorePrivateData(
         IntPtr policyHandle,
         ref LSA_UNICODE_STRING KeyName,
         ref LSA_UNICODE_STRING PrivateData
    );

VB Signature:

Declare Function DefaultPassword Lib "advapi32.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

C++ sample code:

https://docs.microsoft.com/en-us/windows/win32/secauthn/protecting-the-automatic-logon-password

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/protecting_the_automatic_logon_password.asp

C# sample code:

see LsaRetrievePrivateData

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions