Rev 414 | Rev 633 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | reyssat | 1 | |
2 | # Input variables: authdef=def file. |
||
3 | # Parameters: auth_user, auth_password. |
||
4 | |||
468 | bpr | 5 | auth_test=ERROR |
6 | auth_real_login=ERROR |
||
7 | |||
8 | |||
20 | reyssat | 9 | ldap_find=!sh which ldapsearch |
10 | !if $ldap_find issametext $empty |
||
11 | auth_test=ERROR no_ldap |
||
12 | !exit |
||
13 | !endif |
||
14 | |||
15 | ldap_host=!defof class_ldap_host in $authdef |
||
468 | bpr | 16 | !!default ldap_host=ldap.u-psud.fr |
17 | |||
20 | reyssat | 18 | ldap_port=!defof class_ldap_port in $authdef |
19 | !default ldap_port=389 |
||
468 | bpr | 20 | |
20 | reyssat | 21 | ldap_version=!defof class_ldap_version in $authdef |
22 | !default ldap_version=3 |
||
468 | bpr | 23 | |
20 | reyssat | 24 | ldap_base=!defof class_ldap_base in $authdef |
468 | bpr | 25 | !!default ldap_base=ou=people,dc=u-psud,dc=fr |
26 | |||
20 | reyssat | 27 | ldap_branch=!defof class_ldap_branch in $authdef |
468 | bpr | 28 | !!default ldap_branch=ou=people,dc=u-psud,dc=fr |
29 | |||
20 | reyssat | 30 | ldap_uid=!defof class_ldap_uid in $authdef |
468 | bpr | 31 | !!default ldap_uid=uid |
20 | reyssat | 32 | |
468 | bpr | 33 | #ldap_id=!replace internal " by in $ldap_uid=$(wims_read_parm[1]),$ldap_branch,$ldap_base |
34 | ldap_id=!replace internal " by in $ldap_uid=$(wims_read_parm[1]) |
||
20 | reyssat | 35 | |
468 | bpr | 36 | ldap_login=!defof class_ldap_login in $authdef |
37 | !default ldap_login=supannAliasLogin |
||
20 | reyssat | 38 | |
468 | bpr | 39 | !if $ldap_login=$empty or $ldap_uid=$empty or $ldap_base=$empty \ |
40 | or $ldap_branch=$empty or $ldap_host=$empty |
||
41 | auth_test=ERROR no_ldap_config |
||
42 | !exit |
||
43 | !endif |
||
44 | |||
45 | ##sleep 600 |
||
46 | ##kill -9 `pidof monprog` |
||
47 | ldap_search=!sh ldapsearch -x -h $ldap_host -p $ldap_port -b "$ldap_base" '$ldap_id' -D "$ldap_id , $ldap_base" -w '$(wims_read_parm[2])' |
||
48 | |||
20 | reyssat | 49 | ldap_cnt=!linecnt $ldap_search |
50 | !for i=1 to $ldap_cnt |
||
51 | l=!line $i of $ldap_search |
||
468 | bpr | 52 | field=!word 1 of $l |
53 | |||
54 | !if $field iswordof $ldap_login: |
||
55 | auth_real_login=!word 2 of $l |
||
56 | !endif |
||
57 | |||
20 | reyssat | 58 | !if $l issametext result: 0 Success |
468 | bpr | 59 | auth_test=$auth_real_login |
20 | reyssat | 60 | !endif |
468 | bpr | 61 | |
20 | reyssat | 62 | !next i |
468 | bpr | 63 | !if $auth_test=OK |
64 | auth_test= $auth_real_login |
||
65 | !endif |
||
20 | reyssat | 66 | |
468 | bpr | 67 | !!debug $auth_real_login $auth_test \ |
68 | !!ldapsearch -x -h $ldap_host -p $ldap_port -b "$ldap_base" '$ldap_id' -D "$ldap_id , $ldap_base" -w '$(wims_read_parm[2])'\ |
||
69 | !!$ldap_search |
||
70 | |||
20 | reyssat | 71 | auth_error=$wims_exec_error |
72 | wims_exec_error= |
||
73 | |||
468 | bpr | 74 | |
75 | !!!for i=1 to $ldap_cnt |
||
76 | !! l=!line $i of $ldap_search |
||
77 | !! field=!word 1 of $l |
||
78 | !! !if $field iswordof supannAliasLogin: |
||
79 | !! auth_real_login=!word 2 of $l |
||
80 | !! !endif |
||
81 | !! !if $l issametext result: 0 Success |
||
82 | !! auth_test=OK |
||
83 | !! !endif |
||
84 | !!!next i |
||
85 | !!!if $auth_real_login=$empty and $auth_test=OK |
||
86 | !! ldap_search=!sh ldapsearch -x -h $ldap_host -p $ldap_port -b "$ldap_base" '$ldap_id' |
||
87 | !! ldap_cnt=!linecnt $ldap_search |
||
88 | !! !for i=1 to $ldap_cnt |
||
89 | !! l=!line $i of $ldap_search |
||
90 | !! field=!word 1 of $l |
||
91 | !! !if $field iswordof supannAliasLogin: |
||
92 | !! auth_real_login=!word 2 of $l |
||
93 | !! !endif |
||
94 | !! !next i |
||
95 | !!!endif |