[K12OSN] LTSP 4.2, fuse and ldap

cliebow at midmaine.com cliebow at midmaine.com
Tue May 9 20:50:52 UTC 2006


Kevin
:you want to create an ldif that looks like this
dn: cn=fuse, ou=Group, dc=ehs,dc=ellsworthschools,dc=org
gidNumber: 2069
sambaSID: S-1-5-21-3781802711-710701864-1625986258-2069
memberUid: cliebow
memberUid: someotherdude
sambaGroupType: 2
objectClass: posixGroup
objectClass: sambaGroupMapping
cn: fuse

#where every user has a memberUid: theirname field in it..you can do this
in bash by reading some parameters from smb.conf

#!/bin/bash

#######collect info from smb.conf and set variables##############
dn=`grep admin /etc/samba/smb.conf|cut -d " " -f5`
suffix=`grep "ldap suffix" /etc/samba/smb.conf|cut -d " " -f4`
netbiosname=`grep netbios /etc/samba/smb.conf|cut -d "=" -f2`
shortened=`grep workgroup /etc/samba/smb.conf|cut -d "=" -f2`
FILENAME=`date  '+%m%d%y'`
SID=`net getlocalsid | cut -d":" -f2 |cut -c2-`
fileserver=puffin
pw=`cat /etc/ldap.secret`
########inputs password##############
echo "THIS IS THE ADD Group SCRIPT FOR $shortened"
echo
echo
echo
echo "here is ldap password-> $pw"
echo
echo "here is ldap suffix-> $dn"
echo
echo "here is the suffix-> $suffix"
echo
echo "here is the date-> $FILENAME"
echo
echo "here is the workgroup name-> $shortened"
echo
echo "here is the netbiosname-> $netbiosname"
echo
echo "Here is your fileserver-> $fileserver"
echo
echo "Does everything look ok (yes/no)"
echo
echo "Looking up all Students"
rm /tmp/gropu.ldif
cat <<EOF>> /tmp/gropu.ldif
dn: cn=fuse, ou=Group, dc=ehs,dc=ellsworthschools,dc=org
sambaSID: S-1-5-21-3781802711-710701864-1625986258-2069
gidNumber: 2069
sambaGroupType: 2
objectClass: posixGroup
objectClass: sambaGroupMapping
cn: fuse
EOF
# then find all users by ldapsearch for allusers

##########Looks up all
students#######################################################
echo "collecting up existing student names"
ldapsearch -LL -x -h localhost -b "ou=People,$suffix" -D "$dn" -w "$pw" -s
sub "(objectClass=sambaSamAccount)" | grep cn: | cut -f2 -d ":"|cut -c2-
>/tmp/Students

#nOW READ ALL USERS FROM /tmp/students
cat /tmp/Students | while read line; do
echo "memberUid: $line">>/tmp/gropu.ldif
done

#finally ldadpadd the whole mess
ldapadd -x -c -h localhost -D "$dn" -w "$pw"  -f /tmp/gropu.ldif


Sorry best i could do in five minutes..chuck




More information about the K12OSN mailing list