Re: Command Line Request for Adding users to group (LDAP)
RalfGesellensetter wrote:
> Am Donnerstag 23 März 2006 16:22 schrieb Knut Yrvin:
>
>>-- Yes, the system admins also ask for a command line tools for
>> handling users.
>
>
> Indeed, this reminds me that I am still looking for the command line /
> script rendering this task:
>
> 1. I have 100 teachers, all in group "teachers".
> 2. I have a new students group "B2006" which has its own common
> subfolder in home0/Transfer/B2006. Write access is set to group
> "B2006".
>
> Now, in order to give all teachers write access to this shared folder, I
> need to join them to group "B2006". With WLUS, I can do so for a single
> teacher. This takes to long time for 100 teachers.
>
> What I need is a command line or script that joins a set of users (I can
> provide a list of teachers to start with) into a given group (B2006).
# Using variables is nice
GROUP=B2006
#First we list all the teachers
for TEACHER in $(getent group teachers | cut -f4 -d: | tr "," " ") ; do
# Then check if teacher is already a member of group $GROUP
id $TEACHER | grep -q "($GROUP)" && continue
# Then we create a small ldif to add the user to the group
echo "dn: cn=$GROUP;ou=Group,dc=skole,dc=skolelinux,dc=no"
echo "changeType: Modify"
echo "add: MemberUid"
echo "memberUid: $TEACHER"
echo
# when all is done feed everything through ldapmodify
done | ldapmodify -xWZD cn=admin,ou=People,dc=skole,dc=skolelinux,dc=no
# OK - Done
> The minimum help I ask for is a command line joining user $U into group
> $G. The maximum I hope for is a command that includes Group $G1 into
> $G2 (all users in G1 will join G2).
Well, wrap it into a script, and you're set
> Thanks a million
Were should I send the bill ?
Sorry, if you wont pay, I wont test it, so , It's completely untested
--
Finn-Arne Johansen
faj@bzz.no http://bzz.no/
Debian-edu developer and Solution provider
EE2A71C6403A3D191FCDC043006F1215062E6642 062E6642
Reply to: