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
jskfanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The_KirschiCommented:
Hi, you can do this with Powershell. Something like this should be helpful:

http://stackoverflow.com/questions/7663219/how-to-authenticate-an-user-in-activedirectory-with-powershell

After creating the script use task scheduler to run it every 5 minutes.

Here is for the scheduled task part:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx
jskfanAuthor Commented:
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_KirschiCommented:
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.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jskfanAuthor Commented:
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)
Lionel MMSmall Business IT ConsultantCommented:
what did you mean
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)

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 computerx (which is in the NOC)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jskfanAuthor Commented:
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 MMSmall Business IT ConsultantCommented:
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
jskfanAuthor Commented:
Ok..Can you provide the correct Syntax, please ?
jskfanAuthor Commented:
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.
jskfanAuthor Commented:
disregard this:
however if I run this :
 net use X: /delete
 then
 net use X: \\computerx /user:test password
jskfanAuthor Commented:
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.
Lionel MMSmall Business IT ConsultantCommented:
c:
net use X: \\computerx /user:test password
if errorlevel 1 msg * /server:computerx Net use failed

c:
net use X: /delete
if errorlevel 1 msg * /server:computerx Net use delete failed
jskfanAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.