Rev 5262 | Rev 11137 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5060 | bpr | 1 | ## INPUT; identifier, class, method (for the moment only ldap) |
5015 | bpr | 2 | ## OUTPUT : wims compatible unique identifier, compatible with class |
5060 | bpr | 3 | ##FIXME php ? |
4 | |||
5 | !read adm/class/authchars |
||
5002 | bpr | 6 | !set limit=2 |
7 | !set limit_while=$[10^$limit] |
||
5060 | bpr | 8 | |
9 | !distribute items $wims_read_parm into login,cl,meth |
||
5002 | bpr | 10 | !set login=!lower $login |
5055 | bpr | 11 | !if $login=$empty |
12 | error=login_empty |
||
13 | !exit |
||
14 | !endif |
||
5031 | bpr | 15 | !set login_ext=$login |
5060 | bpr | 16 | !if $meth!=$empty |
17 | !set meth_=!word 1 of $meth |
||
18 | !bound meth_ within ldap default $empty |
||
19 | !set ldap_id=!word 2 of $meth |
||
20 | !if $ldap_id!=$empty and $meth_ !=$empty |
||
21 | !goto ldap |
||
22 | !exit |
||
23 | !endif |
||
24 | !endif |
||
25 | |||
26 | |||
5002 | bpr | 27 | !set login=!text select $char_alnum in $login |
28 | !set login=!char 1 to $[$login_max -$limit] of $login |
||
5028 | bpr | 29 | !!set cl=!replace internal / by , in $cl |
30 | !set cl=$(cl[1]) |
||
31 | !if $cl=$empty |
||
32 | !reset login |
||
33 | !exit |
||
34 | !endif |
||
5060 | bpr | 35 | cnt=0 |
36 | u_exists=yes |
||
37 | login_init=$login |
||
38 | !while $u_exists=yes and $cnt<$limit_while |
||
5002 | bpr | 39 | !if $cnt>0 |
40 | login=$login_init$cnt |
||
41 | !endif |
||
5031 | bpr | 42 | !set tt1=!lookup $login_ext in wimshome/log/classes/$cl/.teacherlist_external |
43 | !set tt2=!lookup $login_ext in wimshome/log/classes/$cl/.userlist_external |
||
44 | !if $tt1!=$empty or $tt2!=$empty |
||
5262 | czzmrn | 45 | !! user can be both in .userlist and in .teacherlist (see r5260) |
46 | !if $tt1=$tt2 |
||
47 | login=$tt1 |
||
48 | !else |
||
49 | login=$tt1$tt2 |
||
50 | !endif |
||
5031 | bpr | 51 | !exit |
52 | !endif |
||
53 | !read adm/class/userinclass $cl,$login |
||
54 | !set u_exists=$script_reply |
||
5002 | bpr | 55 | !increase cnt |
5060 | bpr | 56 | !endwhile |
57 | !if $cnt>=$limit_while |
||
5002 | bpr | 58 | !reset login |
5060 | bpr | 59 | !endif |
5121 | bpr | 60 | !if $login=$empty |
5242 | bpr | 61 | error=login_missing |
62 | missing=!append item $login_ext to $missing |
||
5121 | bpr | 63 | !endif |
5060 | bpr | 64 | !exit |
65 | :ldap |
||
66 | |||
5072 | bpr | 67 | !if $ldap_uid!=$ldap_login and $ldap_login notsametext $empty |
7403 | bpr | 68 | !set login=!sh ldapsearch -x -LLL -t -H ldap://$ldap_auth:$ldap_port -b "$ldap_base" $ldap_uid="$login" $ldap_login | grep -v "^[d]n:" |
5060 | bpr | 69 | !set login=!replace internal : by = in $login |
70 | !set login=!getopt $ldap_login in $login |
||
71 | !set login=!text select $char_alnum in $login |
||
72 | !set login=!char 1 to $[$login_max -$limit] of $login |
||
7403 | bpr | 73 | !set login_char=!charcnt $login |
74 | !if $login_char=3 |
||
75 | !set login=$(login)0 |
||
76 | !endif |
||
5060 | bpr | 77 | !endif |
5121 | bpr | 78 | !if $login=$empty |
79 | error=login_empty |
||
80 | !exit |
||
7403 | bpr | 81 | !endif |