Reputation: 6426
How to create windows user using some command line tool or windows API or .NET without hard-coding the password, I need a way to create a user with some password without actually knowing this password, (The program knows only its hash for example).
For example:
Any method to create a windows user with a spicific password will be like this:
UsersUtil.CreateUser("username", "SpIcif1c_Passw0rd");
I need an the code to be like this:
UsersUtil.CreateUser("username", "7604905d86ed36b69a657366e5b5c35f");
//"7604905d86ed36b69a657366e5b5c35f" is the hash for SpIcif1c_Passw0rd for example
I need the code of this CreateUser
method or something similar!!
Upvotes: 1
Views: 312
Reputation: 36328
Unfortunately, there are two problems with this:
To the best of my knowledge Windows doesn't provide any supported mechanism. It might be possible to do this by manipulating the SAM directly, but there's no guarantee that what works today will work tomorrow.
In Windows, the password hash is a password-equivalent, i.e., anyone who knows the hash can (under certain circumstances) access the account as if he or she had the password. So using the hash rather than the password doesn't actually give you the security benefit you're presumably aiming for. (Google "pass the hash" for more information.)
If you post another question describing your scenario, we may be able to suggest alternative approaches, though I'm afraid this is typically an awkward problem to solve. Or, if you prefer, you can email me directly (see my profile for contact details) and I may be able to help.
Upvotes: 1