Third Party Applications August 13, 2004 at 2:37 am

OS X Server Add User Script

Quick script that will allow you to add a user from the Command Line

Get the script from the Downloads section.This script leverages the dsimporexport command to create an import file and then import it to either the NetInfo or the LDAP domain on your server.

To create a user with a shortname of “joel”, a long name of “Joel Rennich” a password of “test”, and a home on “www.afp548.com” you’d use this:


adduser -s joel -n "Joel Rennich" -h www.afp548.com -p test

That will generate a dsimportexport file at /tmp/importfile.txt that you can then load into Workgroup Manager.

To do this all at once you can use this:


adduser -s joel -n "Joel Rennich" -h www.afp548.com -p test -L -A adminuser

Which will prompt for your admin password and then import the dsimportexport file into the LDAP database on the server.

The script is pretty heavily commented, so take a look at it for in depth usage information. Keep in mind that this script assumes that Workgroup Manager is in /Applications/Server. If it isn’t adjust the script as necessary.

No Comments

  • This script returned errors. So I made some changes and got it to work. You
    can get the modified script at:

    http://manuel.noriegaonline.com/files/adduser

  • Many thanks to Josh and Manuel. This scripts saved me a LOT of time.
    Manuel’s additions of MAIL, QUOTA, etc. are a godsend.

    Manuel chose to have FULL NAME always be the same as SHORT NAME
    bypassing the check for FULL NAME. If you leave full name off, the script is
    already set up to use Short name.

    I revised the script to allow for FULL NAME to differ as well as changed the
    check on whether FULL NAME is set. This now allows for full names with
    spaces in them. We use "user – domain.com", for example, as our full
    names.

    Updated script is here:

    http://www.spinhost.ca/downloads/adduser

  • Some people (namely, I) still have a need for this app. When I tried to use it, I found that some of the feature were inadvertently removed during mods. So I’m doing my part to bring it back to life. I tried to reactivate the lost features, as well as expanding it a touch., I added a parameter to allow appending to a file so that you can batch the import process and create one file to import via wgm. Also allowed for creating the home dirs in another location.

    The file has been posted in the files section.

    Thanks for giving me an interesting challenge to start shell programming!

    bob

Leave a reply

You must be logged in to post a comment.