Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Dodawanie LDAP
- echo -n "Podaj imie: "
- read imie
- echo -n "Podaj nazwisko: "
- read nazwisko
- echo " "
- echo "Imie: " $imie "Nazwisko: " $nazwisko
- echo " "
- echo -n "Podaj opis: "
- read opis
- echo " "
- echo -n "Podaj haslo ldap: "
- read -s haslo
- echo " "
- echo -n "Podaj ponownie haslo: "
- read -s haslo2
- echo " "
- if [ "$haslo" -ne "$haslo2" ];
- then
- echo " "
- echo -n "Hasla roznia sie "
- echo " "
- blad=0;
- while [ $blad -le 0 ]; do
- echo " "
- echo -n "Podaj haslo ldap: "
- echo " "
- read -s haslo
- echo -n "Podaj ponownie haslo "
- read -s haslo2
- echo " "
- blad=1;
- if [ "$haslo" -ne "$haslo2" ]; then
- echo "Hasla roznia sie "
- blad=0;
- fi
- done
- fi
- imie=$(echo $imie | tr [:upper:] [:lower:])
- nazwisko=$(echo $nazwisko | tr [:upper:] [:lower:])
- litera=$(echo $imie |cut -c 1)
- username=$litera$nazwisko
- uidnumber=$(ldapsearch -x -LL uidnumber | grep "uidNumber:" | cut -d" " -f2 | sort -n -r | head -1)
- echo "Ostatni uidNumber: " $uidnumber
- uidnumber=$[$uidnumber+1]
- echo "Nowy uidNumber: " $uidnumber
- gidnumber=$(ldapsearch -x -LL gidnumber | grep "gidNumber:" | cut -d" " -f2 | sort -n -r |head -1)
- echo "gidNumber: " $gidnumber
- echo "Login: " $username
- echo "dn: cn="$username",dc=lab,dc=pl" >ldap.txt
- echo "cn: "$username>>ldap.txt
- echo "gidNumber: "$gidnumber>>ldap.txt
- echo "homeDirectory: /home/"$username >>ldap.txt
- echo "objectClass: simpleSecurityObject" >>ldap.txt
- echo "objectClass: person" >>ldap.txt
- echo "objectClass: posixAccount" >>ldap.txt
- echo "objectClass: top" >>ldap.txt
- echo "sn: "$opis >>ldap.txt
- echo "uid: " $username >>ldap.txt
- echo "uidNumber: "$uidnumber >>ldap.txt
- echo "userpassword: "$haslo >>ldap.txt
- ldapmodify -a -x -D cn=admin,dc=lab,dc=pl -W -f ldap.txt
- if [ "$?" = 0 ];then
- mkdir /home/$username
- chmod 700 /home/$username
- chown $uidnumber:100 /home/$username
- echo " Wykonane "
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement