which Windows C/C++/API function for "net user <Username> /domain"? - windows

Can anyone tell me, by which WINDOWS C/C++/API function I can fetch theAccount expires <date> and Password expires <date> or Nevervalues, just like the commands NET USER /DOMAIN(specially for a "Windows single signed on" user) or NET USER <Username> /DOMAIN does - without the knowledge of the password ?
Thanks a lot

Related

PsExec works only with "runas /netonly", not with -u and -p parameters

What I mean:
If I...
run runas /netonly /user:computername\username cmd
enter the password for the local admin account "username"
then type psexec \\computername cmd
I now have a working shell and can run commands as the local admin user on the remote machine.
However, trying to run this without the runas... and instead with the username and password arguments of psexec returns an access denied error.
Example below:
psexec \\computername -u username -p password cmd
Access Denied
Note: Others seem to also have this issue. My refined questions:
Is this intended behavior?
Why even have the -u and -p?
I have also tried disabling the firewall on both my machine and the target machine, and adding the registry key listed here.
When you initiate a connection with PsExec.exe, it tries to use the credentials you are currently authenticated with to copy the PSEXESVC to the \\$machine\ADMIN$\System32 share VIA SMB, which enables the communication with your PsExec.exe and the $machine's service.
If your currently logged in user account does not have access to \\$machine\ADMIN$\System32 and the ability to install/start services, then this won't work.
I'm assuming if you have access with your user account that this would work.
Here is a very interesting article from 2004 on reverse-engineering of the original implementation. I am pretty sure it has changed in that time with Windows 7 & Windows 10.

Cannot logon windows after changing password via net user newuser command

I was trying to change my windows password via command:
net user Adminstrator newpassword
However, I accidentally did this
net user Administrator "newpassword"
There is no special character in the password
Now I am not able to logon my Administrator account via either newpassword or "newpassword"
Please help.
Thank you.
Best regards,
Apparently it is an issue for Windows password change command, that you cannot put double quotes in the password, and if you did, the command will be executed successfully but nobody knows what the password is.
I resolved this issue via resetting admin password to default following the instruction at:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Config.html
I was lucky I am having this issue with AWS EC2 instance, otherwise I won't be able to resolve like that.
It happens when using escape sequence in command prompt
Run the following command in command prompt with administrator privilege
echo EnteredPassword >> C:\ActualPassword.txt
EnteredPassword is the password that you entered in the command prompt
And your actual password will be available in C:\ActualPassword.txt

Changing Active Directory Password via Batch

I'm trying to write a batch script to automatically change the password of an active directory user.
The:
net user <user> /domain <password>
where <user> & <password> are a user and password of some user on the domain.
Results in:
The request will be processed at a domain controller for
domain .
System error 5 has occurred.
Access is denied.
Edit:
I just found out that you need to be the domain controller to be able to run the command.
Is the a way to change a user's password without being the domain controller?
IT Admins with permissions to change passwords can use the QAD Powershell cmdlets to change passwords for accounts. Here’s an example of the Powershell command to run:
Set-QADUser -Identity <account_name> -Proxy -UserPassword <new_password>
For users without elevated permissions to set passwords on other accounts, there is still a Powershell option. You will need to have the Microsoft ActiveDirectory powershell module installed and know the previous password. Here’s some sample code how to accomplish this:
Set-ADAccountPassword -Identity <ADAccount>
This will then prompt for the previous password, and then ask for the new password twice.
For example if you want your process perform automatically:
Set-ADAccountPassword -Identity $username -OldPassword (ConvertTo-SecureString -AsPlainText $oldPass -Force) -NewPassword (ConvertTo-SecureString -AsPlainText $newPass -Force)

How to add a user into a specific domain using CMD?

In Windows 7, let's say I want to create a user in a specific domain using CMD. If the username is user.name, the password is password and the domain is DMN (the domain my computer is currently connected to), what would the command be? I know the syntax for the net user command is
net user [<UserName> {<Password> | *} [<Options>]] [/domain]
but i've attempted the command
net user user.name password /ADD DMN
and it doesn't work.
What should I do? Is there a proper command for this?
Thanks in advance.
When adding a new domain user with NET USER you don't name the domain. The command executes on the current domain as below.
NET USER user.name password /ADD /DOMAIN

Single line command for Run as a different user on Windows 7 that contains a password also

Is there any single line command for Run As Different User in Windows 7.
I am using following command but then it ask for password
runas /user:USER-NAME "C:\full\path\of\Program.exe"
Is there any way to supply password also in above line ? Actually i am launching application from other application so I don't want any user interaction But in above command it ask user for PASSWORD
PsExec in the MS SysInternals suite:
psexec -user Administrator -p Passwd "xcopy a.xml \\server_over_there\c$\A.xml"
In case the local user is NOT what you need and a specific DOMAIN user is, use:
/user Username in form USER#DOMAIN or DOMAIN\USER
(USER#DOMAIN is not compatible with /netonly)

Resources