AppleScript: Waiting for a user to enter user name and password

I'm currently working on an AppleScript designed to automate binding a computer to Active Directory and another script to install a login certificate. While you can create a UNIX shell script for the Active Directory binding, I found that you have to have your user name and password in the script itself and this system will be deployed by multiple people.
So instead I'm doing an GUI Automation AppleScript of Directory Utility. What I'd like to do is have the script to wait for the admin user (who will be remoting in by ARD) to enter their Network user and password, click okay and then continue the script to quit the program and then run a self-destruct (which I'd also appreciate any advice about doing in AppleScript)
Here's the script so far, which I've set up successfully:
activate application "Directory Utility"
tell application "System Events"
  click text field 1 of row 1 of table 1 of scroll area 1 of group 1 of group 1 of window "Directory Utility" of application process "Directory Utility"
  click button 1 of group 1 of group 1 of window "Directory Utility" of application process "Directory Utility"
  click text field 2 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "EXAMPLE.COMPANY.com"
  click UI element 3 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click radio button "Administrative" of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click checkbox "Allow administration by:" of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 1 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExamplePS NA"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 2 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleNA"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 3 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleNATemps"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 4 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleTeam 1"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 5 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleTeam 2"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 6 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleTeam 3"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 7 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleDesktop Admins"
  click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  click row 8 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
  keystroke "GroupExampleDomain Admins"
  click button "Bind…" of sheet 1 of window "Directory Utility" of application process "Directory Utility
<<WAIT LINE HERE FOR NETWORK ADMIN AND AND PASS, THEN USER WILL CLICK OKAY, THEN CONTINUE SCRIPT>>
<<QUIT ACTIVE DIRECTORY>>
<<SELF-DESTRUCT>>
end tell
It isn't a real command prompt like if you're changing System Preferences or something. It's a specialized prompt specifically for Directory Utility. However, I do need to know how to make AppleScript wait for a password for a standard Password Prompt for adding a certificate to the login keychain through Keychain Access. I've also done pretty much the same thing as above for that script.
Any tips would be GREATLY appreciated.

Yeah, I know GUI Scripting is not the best way, but I couldn't find a successful variable system for the following script. The other issue is that I'd prefer to send this by ARD and have ARD ask for a User Name and Password, but I've found there's no way to do that. Then again, I can't send the AppleScript purely remotely either.
What I mean by self-destruct is simply I only want the Active Directory binding script to run once upon login to the primary admin user and then delete itself so it doesn't get run again. The login certificate script I want to run once on each new user who logs in (so I'll likely be putting it in the "User Template") and then delete itself so it doesn't run the next time they log in. I can't figure out any way to hit those buttons through a shell script.
Here's the original UNIX shell script: (This is what I'm using temporarily until I figure out a solution that doesn't require my user name and password to be embedded)
#! /bin/bash
MACNAME=$(scutil --get ComputerName)
dsconfigad -add "CORP.DOMAIN.NET" \
-username USER \
-password PASS \
-computer $MACNAME \
-mobile disable \
-mobileconfirm disable \
-localhome enable \
-useuncpath enable \
-shell /bin/bash \
-ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net \
-force \
-localpassword "PASSWORD" \
-groups "GROUPS"
And here is the Certificate Installation AppleScript
activate application "Keychain Access"
tell application "Finder" to open POSIX file "/FolderName/Certificate.crt"
delay (3)
tell application "System Events" to tell process "Keychain Access"
  click button "Add" of window "Add Certificates"
  click button "Always Trust" of group 3 of sheet 1 of window "Keychain Access"
end tell
Thanks for the help. I really appreciate it. This is a rather new field for me and most of my knowledge comes from Google Searches and about a billion tabs trying to find answers.

Similar Messages

  • How to force users to enter their ID and password ?

    I am considering installing AirPort Extreme at our office. We don't want guests connecting to our network. is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.

    How to force users to enter their ID and password?
    is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.
    The AirPort Extreme does not have the features necessary to create a "splash page" that provides basic information about the company and asks users for their identity and password....like you see at most hotels.
    Basically, with an AirPort Extreme, users would have to scan to look for the name of the wireless network to join, and then enter the password to connect.
    The best that you might be able to achieve with the AirPort Extreme is create a "hidden" network, which would require that users know both the name of the wireless network and password to connect.  However, based on experience, this might be more of a hassle than anything else.
    The bottom line.....Apple really designed the AirPort routers for home use, so that might be the best place for them in most cases.

  • "You may need to enter the name and password for an admin" ....

    Hi everyone!
    I'm getting this error when trying to copy files over to a network drive. First, it'll pop up and say:
    "You may need to enter the name and password for an administrator on this computer to change the item named"
    At the same time, it will create an empty file on the target drive. When I click "Continue", it asks me for my username and password, which I happily enter. At that point, it errors out and says "The operation cannot be completed because an item with the name "xyz" already exists".
    I've tried repairing permissions, chmod 777'ing a file, etc. It did work for a short time (it seemed to work while I was at work, but once I arrived home, it quit working and hasn't worked since.) I've tried rebooting as well.
    Does anyone have any suggestions? I'm really puzzled over this!
    Thanks!

    Actually I get some other errors as well:
    "You may need to enter the name and password..."
    Then I click continue...
    "The item "filename" contains one or more items you do not have permission to read. Do you want to copy the items you are allowed to read?"
    I click continue...
    "The operation cannot be completed because you do not have sufficient privileges for some of the items."
    I am copying a text file made from textedit. I have logged into the shared drive on my iMac. I get the same errors coying to my own user folder. Same account on both machines.
    But it does copy a blank version of the file to the drive and adds the .txt extension to it. Then I can delete it from the share.

  • Hi. I am using a time capsule for few PC s. I have made 5 different account to access time capsule. but in windows when i enter account name and password for one account, i cannot access other accounts, because windows saves username

    Hi. I am using a time capsule for few PC s. I have made 5 different account to access time capsule. but in windows when I enter account name and password for one account, i cannot access other accounts, because windows saves username. how can i prevent this from happenning. I really need to access all my accounts and dont want it to save automaticlly.

    Why have 5 accounts if you need to access all of them.. just have one account?
    Sorry I cannot follow why you would even use the PC to control the Time Capsule. Apple have not kept the Windows version of the utility up to date.. so they keep making it harder and harder to run windows with apple routers.

  • Cant fix - "select a certificate or enter a name and password for network"

    iMac 27 - inch, Mid 2010
    Software OS X 10.8.2 (12C60)
    I cant seem to fix this message when going online, nore have I managed to find any help with it.
    everytime my imac27 2010 sleeps it goes offline then this message appears...
    "select a certificate or enter a name and password for network (whatever network im trying to connect to)"
    it continues with...
    "no certificate selected"
    "account name"
    "password"
    as a result I have to play around with "join other network" every time I want to join my own network.
    it was so anoying that I decided to reinstall everything from scrach, so I backed everything to time machine. but I couldnt restore as im on snow leapard and dont have an original disc with me. I moved countries so the apple store isnt round the corner any more :/ (disc would need to be shipped in)
    whats interesting in my mac did not have this wifi conection problem when I took it to another location. only from home. But every other devise does not have this problem even at home...
    any help really appreciated

    Hi, this has worked for a few...
    Make a New Location, Using network locations in Mac OS X ...
    http://support.apple.com/kb/HT2712
    10.7 & 10.8…
    System Preferences>Network, top of window>Locations>Edit Locations, little plus icon, give it a name.
    10.5.x/10.6.x/10.7.x instructions...
    System Preferences>Network, click on the little gear at the bottom next to the + & - icons, (unlock lock first if locked), choose Set Service Order.
    The interface that connects to the Internet should be dragged to the top of the list.
    10.4 instructions...
    Is that Interface dragged to the top of Network>Show:>Network Port Configurations.
    If using Wifi/Airport...
    Instead of joining your Network from the list, click the WiFi icon at the top, and click join other network. Fill in everything as needed.
    For 10.5/10.6/10.7/10.8, System Preferences>Network, unlock the lock if need be, highlight the Interface you use to connect to Internet, click on the advanced button, click on the DNS tab, click on the little plus icon, then add these numbers...
    208.67.222.222
    208.67.220.220
    Click OK.

  • Keeps asking for Select a certificate or enter a name and password for network

    everytime i start my mac it asks for "Select a certificate or enter a name and password for network" and when i'll close it and reopen it, it still asks.
    can somebody help with what am i suppose to do?

    If you are currently showing WiFi status in the menu bar, you would see this icon:
    If you see that near the top right corner, click it and choose "Join other network" from the drop down list.
    If you do not see that icon, then go to System Preferences (under the Apple logo in the menu bar), ciick "Network", then choose "WiFi" and choose something (probably "Assist me" at the bottom) there.

  • Enter your name and password for the server when trying to connect PC and Mac?

    I'm trying to connect my iMac and my WIndows tablet (got it for free) together through my home network.  I open iPhoto, then "Import to Library" ; the connection fails and when I click on "Connect as" up pops this box asking me to "enter your name and password for the server -computer name here-". HELP!!  Where do I find the password?  I've tried everything possible and no go.
    I am running Windows 8 and Lion.

    Hi Tom! Welcome to the Apple discussions. You have posted in the forum dedicated to the application Appleworks. Your question is better to post in the forum for MacOs 10.6. In that forum you have several sub-forums to choose from.

  • How to remove "Enter your name and password for the server"

    Hi there,
    I have a Mac Book Pro from 2008. I have mountain lion running on it.
    We used to have a server (pc) in the office that I connected to and stored all of my photos and videos etc.
    We have jsut upgraded to a new server and this connects great!
    However, ever since the switch, when i open keynote, imovie or iphoto i get the error message:
    "Enter your name and password for the server "192.168.0.10".
    (it is trying to connect to the old server)
    I have tried a bunch of fixes online but i dont think they are relevant for this issue - or i cant find what they want tme to change or remove.
    Any help would be great! having this pop up while trying to create things slows everything down.
    thanks!!

    Hi Tom! Welcome to the Apple discussions. You have posted in the forum dedicated to the application Appleworks. Your question is better to post in the forum for MacOs 10.6. In that forum you have several sub-forums to choose from.

  • "You may need to enter the name and password for an administrator"

    I am suddenly getting this message when I try to copy a file from my new Macbookpro to my Powerbook running 10.4.9.
    "You may need to enter the name and password for an administrator on this computer to change the item named "file i am trying to transfer". stop continue
    I hit continue and get the error message: "The item "that I am transferring" contains one or more items you do not have permission to read. Do you want to copy the items you are allowed to read?
    I say continue and get the error: "The operation cannot be completed because you do not have sufficient priveleges for some of the items."
    My network was working fine until today. I can copy fine to all other computers on my network. But not this one.
    If I initiate a transfer from the Powerbook, everything works fine.
    Ideas?

    I experience the exact issue between a macbook pro and an iMac.
    I can access the files locally on my macbook, copy them on usb-stick, etc.
    but ... when I try to copy the files to my iMac ... it fails with the sequence of questions you mentioned.
    However!
    I can copy whatever I like from my macbook if I use my wifes account.
    So...
    Imho there is a problem when the SAME account is used on both systems.
    In my case, I copied my account from the macbook to the (new) iMac.
    Mac OS X seems to be confused when the same accounts are used.
    Does this makes sense?
    All help welcome.
    Luc

  • Help with "You may need to enter the name and password for an administrator

    I'm trying to move files from one of my external harddrives to another external harddrive. I keep getting this message "You may need to enter the name and password for an administrator on this computer to change the item named "Documents". I also get this for other folders I want to move, but not all folders on that drive.
    I am the administrator, and it only gives me an "ok" button, no option to enter my name and password again.
    Any ideas?

    I have the same problem, trying to copy items from external hard disk to another computer on the network. I can copy without problems from external hard disk to my laptop. But not from external hard disk to another computer on the network, and neither from my laptop to another computer on the network, but ONLY if the files I try to copy from my laptop were first copied from that external hard drive. It keeps popping me up with this message. Please help, or fix.

  • LAN Networking / UUID error - "You may need to enter the name and password"

    I'm having an issue with networking via ethernet cable. I'm connecting to Windows Vista via ethernet from my macbook pro.
    Everything was going hunky dory until today when I connected and tried to copy a folder over from my desktop to a folder on my vista machine.
    The error is a three tier one, as follows:
    1. +"You may need to enter the name and password for an administrator on the computer to change the item name "..." - stop or continue"+
    2. +"The item "..." contains one or more items you do not have permission to read. Do you want to copy the items you are allowed to read?" - stop or continue+
    3. +"The operation cannot be completed because you do not have sufficient privileges for some of the items."+
    This happens with all files and folders that I try to transfer over. I have full permissions on both ends to do this and the folders have full permissions.
    I've done a bit of trawling and have found out that if you goto: system prefs - accounts (click unlock) - right click on the user in question - advanced options, you can click on the "create new" button under UUID and create a new UUID digit, then restart. This works!!!!... But...
    ...it only works for a little while. After transferring a few folders or files accross, it comes up with the three tiered warning: "you may need to enter the name and... etc etc."
    This is really annoying.
    I've found my initial answers on this thread: http://discussions.apple.com/thread.jspa?threadID=1823835&tstart=45, but this issue seems to go one step further by constantly not allowing me access
    Has anyone got any thoughts about what I can do? I've also tried running applejack on startup, but this doens't work either...

    Actually I get some other errors as well:
    "You may need to enter the name and password..."
    Then I click continue...
    "The item "filename" contains one or more items you do not have permission to read. Do you want to copy the items you are allowed to read?"
    I click continue...
    "The operation cannot be completed because you do not have sufficient privileges for some of the items."
    I am copying a text file made from textedit. I have logged into the shared drive on my iMac. I get the same errors coying to my own user folder. Same account on both machines.
    But it does copy a blank version of the file to the drive and adds the .txt extension to it. Then I can delete it from the share.

  • "Enter your name and password to update the RSS feed"

    I keep getting a pop-up from Safari (even when it's in the background) that says:
    +*Enter your name and password to update the RSS feed*+
    How on earth do I disable this? It is asking for a username and password for Twitter so I must have clicked an RSS feed link there, but after searching like mad, I can't figure out where Safari looks for RSS at on my system.

    Same here,
    It says:
    <<Enter your name and password to update the RSS feed.
    To update teh RSS feed "Gmail - Inbox for [email protected]", you need to log in to the area "New mail feed" on mail.google.com. Your password will be sent in clear text.
    Name: (blank field)
    Password: (blank field)
    O Remember this password in my keychain. >>
    This started occurring immediately after updating to safari 4.
    I tried disabling the automatic RSS updates in safari preferences, set it to "never" as suggested, but the annoying window keeps on popping up.
    So the original question is still not answered for me.
    It seems to me that all people reporting this problem are OSX Tiger (10.4.11) users

  • Store last user on "Login Window: Name and Password"

    I have set my login window to display as "Name and password"
    Is there any way to make a certain user always appear in the Username box - much like you can do on Windows? Basically, I want to only have to enter in a password and not the username everytime.
    Thanks in advance.

    I think the only way to do that is to set your login window to show "list of users" instead of "name and password". Why don't you do that?

  • No place to enter login name and password

    After recent update there is text boxes to enter user name and password for signing in with the skype name but they are read only. Even mouise can not point to any of those controls.What is going on?I am using skype long time and this is the first I see anything like that.Is it usual microsoft attempt of humor?

    What version of Windows are you on (XP, Vista, Windows 7, Windows 8 )? Is it 32-bit or 64-bit? http://support.microsoft.com/kb/827218 What is the version of Internet Explorer installed on your computer? In Internet Explorer go to Help -> About Internet Explorer. P.S. Please, don’t say that you are not using Internet Explorer. This is irrelevant. Skype depends on Internet Explorer. 

  • Can't connect to WPA protected wifi. Prompt says choose a certificate OR enter account name and password? Huh

    I cannot connect to wifi using my MacBook, my phone and Xbox work but there is no prompt for the WPA password and when I go to the diagnostics page it prompts me to choose a certificate or enter an account name and password? What account name are they referring to? I have entered everything I could think of; the actual connection name and password, the Internet provider login email, my MacBook account name as password... What the heck. After I try, it says connecting for awhile, then fails...

    Select the network from the Airport icon drop down in the menu. Then put in the password.

  • Enter Account Name and Password

    "To use this machine for Automatic Downloads, enter your Apple ID and password."
    This pop-up window appears again and again and again and again.........  what happened to iTunes now?  I don't want to have to keep entering my password.  I've done it several times but the window always pops up.  How do I get rid of this once and for all?  Thanks much and merry Christmas!!
    - .02 cents worth

    sign in to your iTunes account; at the bottom of the account page, where it says "Reset all warnings for buying and downloading", click on the "Reset" button; sign out of your account; restart iTunes to see if you still receive the message box about using the machine for automatic downloads. Additionally, if you now go to iTunes preferences, the check boxes on the store pane will be dimmed.

Maybe you are looking for