Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. How to get current user's PassWord programmatically? [modified]

How to get current user's PassWord programmatically? [modified]

Scheduled Pinned Locked Moved Windows API
tutorialquestion
3 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jakeyjia
    wrote on last edited by
    #1

    i have a application need to verify by the string of current User Name & PWD. I can get current User Name by using : BOOL GetUserName( LPTSTR lpBuffer, // name buffer LPDWORD nSize // size of name buffer ); but how to get the password? i know that under Windows2000, we can get it by rewrite the GINA. but i know there have changed GINA to Windows Vista Credential Provider. anybody have some hint to me? show me, please~ :(

    S 1 Reply Last reply
    0
    • J jakeyjia

      i have a application need to verify by the string of current User Name & PWD. I can get current User Name by using : BOOL GetUserName( LPTSTR lpBuffer, // name buffer LPDWORD nSize // size of name buffer ); but how to get the password? i know that under Windows2000, we can get it by rewrite the GINA. but i know there have changed GINA to Windows Vista Credential Provider. anybody have some hint to me? show me, please~ :(

      S Offline
      S Offline
      Slam Master A
      wrote on last edited by
      #2

      First of all - there is no simple WIN32 API call to retrieve the user's Windows password. That should be of no surprise to you. Consider the consequences of allowing any executable to retrieve the user's password. That would not be a safe system. Since the user is probably logged in when your code is run, use the user's security token for validation - never never never use a password in clear text for verification. That would be unsafe, and just plain dumb! (Sorry!) If your application ever needs to confirm the user's credentials, you must prompt the user for credentials. The user's credentials should never be used without the user's knowledge. Check out the CredUIPromptForCredentials API - it exists in XP, 2003, Vista and Longhorn...

      J 1 Reply Last reply
      0
      • S Slam Master A

        First of all - there is no simple WIN32 API call to retrieve the user's Windows password. That should be of no surprise to you. Consider the consequences of allowing any executable to retrieve the user's password. That would not be a safe system. Since the user is probably logged in when your code is run, use the user's security token for validation - never never never use a password in clear text for verification. That would be unsafe, and just plain dumb! (Sorry!) If your application ever needs to confirm the user's credentials, you must prompt the user for credentials. The user's credentials should never be used without the user's knowledge. Check out the CredUIPromptForCredentials API - it exists in XP, 2003, Vista and Longhorn...

        J Offline
        J Offline
        jakeyjia
        wrote on last edited by
        #3

        Thanks~ my target is that check the user's credential who want to use my Application. so i found i needed to know what the PWD is. i only want to check if they are match. so i found a API function LogonUser(). it's work! --------------------------------------------------------------- btw: i have see the MSDN about LogonUser(): In Windows 2000, the process calling LogonUser requires the SE_TCB_NAME privilege. The privilege does not need to be enabled. The LogonUser function enables the privilege as necessary. If the calling process does not have this privilege, LogonUser fails and GetLastError returns ERROR_PRIVILEGE_NOT_HELD. Beginning with Whistler, this privilege is no longer required. i want to know how to set the SE_TCB_NAME privilege under Windows2000.:)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups