LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2013, 12:09 PM   #1
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Rep: Reputation: Disabled
script a response to a password prompt


I have a script that joins a linux user to AD. It runs the net ads join -U userid@domain and it always prompts for a password. I would like to store that password as a variable and provide it as input to the net ads join command that way the script doesn't stop for user input. Is that possible?
 
Old 07-11-2013, 12:21 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by Rogue45 View Post
I have a script that joins a linux user to AD. It runs the net ads join -U userid@domain and it always prompts for a password. I would like to store that password as a variable and provide it as input to the net ads join command that way the script doesn't stop for user input. Is that possible?
Yes. Read the man page on the net command. Pay particular attention to the -U flag, since it tells you how to specify a password:
Quote:
Originally Posted by net man page
[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]
Putting "-U username%mypassword@domain" is what you need.
 
1 members found this post helpful.
Old 07-11-2013, 12:22 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Code:
man net
gets you the manual

Quote:
Originally Posted by man net
Code:
[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]
       Join a domain. If the account already exists on the server, and [TYPE] is MEMBER, the
       machine will attempt to join automatically. (Assuming that the machine has been created in
       server manager) Otherwise, a password will be prompted for, and a new account may be
       created.

       [TYPE] may be PDC, BDC or MEMBER to specify the type of server joining the domain.

       [UPN] (ADS only) set the principalname attribute during the join. The default format is
       host/netbiosname@REALM.

       [OU] (ADS only) Precreate the computer account in a specific OU. The OU string reads from
       top to bottom without RDNs, and is delimited by a '/'. Please note that '\' is used for
       escape by both the shell and ldap, so it may need to be doubled or quadrupled to pass
       through, and it is not used as a delimiter.
 
1 members found this post helpful.
Old 07-11-2013, 01:23 PM   #4
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Original Poster
Rep: Reputation: Disabled
Whoops i saw that but thought the % was Windows or something. Thanks guys. i used net ads join -U ${ADMIN_ACCT}@${DOMAIN}%${PASSWORD} so i could pass all the variables in from command line.
 
1 members found this post helpful.
Old 07-11-2013, 01:56 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by Rogue45 View Post
Whoops i saw that but thought the % was Windows or something. Thanks guys. i used net ads join -U ${ADMIN_ACCT}@${DOMAIN}%${PASSWORD} so i could pass all the variables in from command line.
Thanks for posting back the solution that worked for you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Password Response es0teric Programming 6 07-31-2008 06:56 PM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 12:16 PM
password prompt ? wr3ck3d Linux - General 5 03-20-2003 09:54 PM
No Password Prompt hockeydude Linux - General 3 04-18-2001 05:29 AM
no password prompt stroh78 Linux - General 3 01-02-2001 10:22 AM


All times are GMT -5. The time now is 08:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration