editing group

Print Friendly, PDF & Email

Randy just asked me to add Karishma Chadha and Smaranda Sandu to the cs251stu group.

There are basically two strategies:

1. edit the /etc/group entry, extract the whole group, use the migrate_group.pl script to convert it to ldif format, then delete the old LDAP entry using ldapdelgroup and use ldapadd2 to insert the new one.

2. edit the /etc/group entry.  Extract the existing group in LDIF format from LDAP using ldapsearchgroup, edit that to add the new entries, and delete the old and add the new.

Here is what I did:

[root@tempest ~] grep cs251stu /etc/group
cs251stu:*:2726:cs251,fturbak,gdome,rshull,achang4,ahu2,alevy2,choef,dgranger,dsuggs,esegreto,ggoodwin,gwunnava,hbond,hlu,hye,jkilleng,jlu3,jokerlun,klevine2,nshih,okotsopo,rbobbins,rshull,skim22,slee14,ssastry,sshah2,ssunier,swang6,vbrown,vlin,xlu2,ytrujill
[root@tempest ~] emacs -nw !$
emacs -nw /etc/group
[root@tempest ~] grep cs251stu /etc/group
cs251stu:*:2726:cs251,fturbak,gdome,rshull,achang4,ahu2,alevy2,choef,dgranger,dsuggs,esegreto,ggoodwin,gwunnava,hbond,hlu,hye,jkilleng,jlu3,jokerlun,klevine2,nshih,okotsopo,rbobbins,rshull,skim22,slee14,ssastry,sshah2,ssunier,swang6,vbrown,vlin,xlu2,ytrujill,asandu,kchadha
[root@tempest ~] cd /root/acctmp/
[root@tempest acctmp] grep cs251stu /etc/group > cs251stu.group
[root@tempest acctmp] migrate_group.pl cs251stu.group > cs251stu.ldif
[root@tempest acctmp] ldapdelgroup cs251stu
dn: cn=cs251stu,ou=Group,dc=cs,dc=wellesley,dc=edu
objectClass: posixGroup
objectClass: top
cn: cs251stu
gidNumber: 2726
memberUid: gdome
...
delete? y
[root@tempest acctmp] ldapadd2 cs251stu.ldif 
adding new entry "cn=cs251stu,ou=Group,dc=cs,dc=wellesley,dc=edu"
[root@tempest acctmp]

Works!

Even easier, I now have a script “groupupdate” which reads the (updated) entry from /etc/group and does the rest, so just edit /etc/group and use the script.

 

 

 

About CS SysAdmins

The CS Department System Administrators
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *