Avatar of jskfan
jskfan
Flag for Cyprus asked on

Script to login to Active Directory Domain

Script to login to Active Directory Domain

I have an application XYZ, it is LDAP aware. I mean users login to the application using their Active Directory domain user name and pasword.

I want to create a domain user account for instance Test, with password never expires, I need to make a script that simulates login to the domain, then schedule the script to run once every other 5 minutes.

Any help will be very much apprecitade.

Thanks
Scripting LanguagesActive Directory

Avatar of undefined
Last Comment
jskfan

8/22/2022 - Mon
SOLUTION
The Kirschi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jskfan

ASKER
I guess if I can get to the share, that means I can login

net use \\serverX\share /user:test /password:test
example
net use \\serverX\C$ /user:test /password:test

well , now if it is not successful, I need to make a message Popup Saying " Login to ServerX has failed" if it is successful... I do not need to see the message.
The Kirschi

Yes, if you can access the share, then login was successful.

If the connection can not be established with the provided login data, Windows will bring up its own message. Why do you want a different one?

Maybe you can describe a little bit about the purpose you are trying to accomplish. That would maybe help to provide an answer.
jskfan

ASKER
the computer where the script is going to run and the computer where the Message should be displayed are 2 different computers but in the same Network.

Let's say the script runs on Computer1 to access share on ComputerX if it is not successful then the message should be displayed on computer2 (which is in the NOC)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Lionel MM

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jskfan

ASKER
This is an example of a Script that I have not tested yet. It could be that the sysntax is wrong.

I am at the console of Computer1 and running this script:

net use \\ComputerX\Sharename /user:test /password:test





 is not successful then  I need the message to be displayed on computerx (which is in the NOC) and not on the computer1 where I am running the script.

Is it clear ?

Thanks
Lionel MM

I know of no way to do that. Only thing I can think of is for you to run a scheduled task on computer x and then if net use \\ComputerX\Sharename /user:test /password:test fails to do an errorlevel and to then msg that computerx. You could also put net use \\ComputerX\Sharename /user:test /password:test into a script on computer1 and if it errors out to then msg computerx
jskfan

ASKER
Ok..Can you provide the correct Syntax, please ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
jskfan

ASKER
This worked for me in Command prompt
net use X: \\computerx /user:test password
The command completed successfully.

however if I run this :
net use X: /delete
then
net use X: \\computerx /user:test password


I get :
The current directory is invalid.
jskfan

ASKER
disregard this:
however if I run this :
 net use X: /delete
 then
 net use X: \\computerx /user:test password
jskfan

ASKER
This is when it is "Successful"
What I need is when it is not successful   to display the message

I guess the script needs to be run through Windows Host Scripting language, so that it will test if the command completed successfuly it will not pop up the message, but if the message is different than "the command completed successfuly" it will pop the message.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SOLUTION
Lionel MM

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
jskfan

ASKER
Thanks