> On Wed, Jul 27, 2005 at 10:39:14AM +0100, [EMAIL PROTECTED] wrote:
>
>>   I've had a look at the adduser script and it should be straight
>> forward
>> enough to tailer to this purpose, and I can't see any difficulties in
>> writing them - check /etc/ldap.conf for the location of the users &
>> groups, pops the details into an ldif and runs it through the ldap
>
> I'm not sure that such utilities exist, because each environment is
> very different.  On my systems, I'm planning to write own scripts for
> creating, deleting users, etc.  I will be much easier than adaption
> someone's scripts for own purpose.

Each to their own, but most of the stuff is fairly generic. I've written
the scripts to read the ldap settings from the relevent files (the admin
user, and the user & group context).

>
>> client. The one thing I am not sure about is getting the next available
>> uid number, but I'm sure the answer will become apparent.
>
> From my point of view the easiest solution is some directory with files,
> a name of each file is equal to UID of user.  A script should find non-
> existent file with name from UID_min to UID_max and create it.  As an
> optimization it possible to keep list of unused numbers (in file).

Yuch! And what happens if the information gets out of sync. I've come up
with a solution, which was much easier than I had thought -

user_base=`awk '/nss_base_passwd/ {print $2}' /etc/ldap.conf | cut -f1 -d?`
get_next_uid() {

        lastuid=`ldapsearch -LLL -b "$user_base"
"objectclass=posixAccount" |\
                 awk '/uidNumber/ {print $2}' | sort | tail -n1`
        if [ -z "$lastuid" ]; then
                uid=$startuid
        else
                uid=`expr $lastuid + 1`
        fi
}

it pulls out all the uids already assigned, sorts them, takes the last
one, and adds one on (or sets it to startuid if none found). It might fall
over if huge numbers of users are in there, but should work for most.


>
>>   So before I get into the meat of this, I wanted to check if anyone has
>> any suggestions or comments.
>
> How do you export user home directories?

Thats another task - I'm just interested in easily adding and removing
users easily.

If you are interested, I can send you the full scripts - they are pretty
sparse and general, so should be easy to adapt.

Cheers,
Martin








_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to