| rev | 
   line source | 
| 
bsw@1071
 | 
     1 -- check if the corresponding LDAP entry for an LiquidFeedback member
 | 
| 
bsw@1071
 | 
     2 -- object is still existent and updates changed attributes
 | 
| 
bsw@1071
 | 
     3 -- --------------------------------------------------------------------------
 | 
| 
bsw@1071
 | 
     4 --
 | 
| 
bsw@1071
 | 
     5 -- arguments:
 | 
| 
bsw@1071
 | 
     6 --   member: a LiquidFeedback Member object (required)
 | 
| 
bsw@1071
 | 
     7 --   ldap_conn: a ldap connection handle (optional)
 | 
| 
bsw@1071
 | 
     8 --   uid: the uid of the member (optional, required when creating members)
 | 
| 
bsw@1071
 | 
     9 --
 | 
| 
bsw@1071
 | 
    10 -- returns:
 | 
| 
bsw@1071
 | 
    11 --   ldap_conn: an LDAP connection
 | 
| 
bsw@1071
 | 
    12 --   ldap_entry: the found LDAP entry (if any)
 | 
| 
bsw@1071
 | 
    13 --   err: error code in case of an error (string)
 | 
| 
bsw@1071
 | 
    14 --   err2: error dependent extra error information
 | 
| 
bsw@1071
 | 
    15 --   err3: error dependent extra error information
 | 
| 
bsw@1071
 | 
    16 
 | 
| 
bsw@1071
 | 
    17 function ldap.update_member_attr(member, ldap_conn, uid)
 | 
| 
bsw@1071
 | 
    18   
 | 
| 
bsw@1071
 | 
    19   -- do this only for members with ldap authentication
 | 
| 
bsw@1071
 | 
    20   if member.authority ~= "ldap" then
 | 
| 
bsw@1071
 | 
    21     return nil, nil, "member_is_not_authenticated_by_ldap"
 | 
| 
bsw@1071
 | 
    22   end
 | 
| 
bsw@1071
 | 
    23   
 | 
| 
bsw@1074
 | 
    24   local filter = config.ldap.member.uid_filter_map(member.authority_uid or uid)
 | 
| 
bsw@1071
 | 
    25   local ldap_entry, err, err2 = ldap.get_member_entry(filter, ldap_conn)
 | 
| 
bsw@1071
 | 
    26 
 | 
| 
bsw@1071
 | 
    27   if err then
 | 
| 
bsw@1071
 | 
    28     return ldap_conn, nil, "ldap_error", err, err2
 | 
| 
bsw@1071
 | 
    29   end
 | 
| 
bsw@1071
 | 
    30   
 | 
| 
bsw@1071
 | 
    31   -- If no corresponding entry found, lock the member
 | 
| 
bsw@1071
 | 
    32   if not ldap_entry then
 | 
| 
bsw@1071
 | 
    33     member.locked = true
 | 
| 
bsw@1071
 | 
    34     member.active = false
 | 
| 
bsw@1071
 | 
    35     return ldap_conn
 | 
| 
bsw@1071
 | 
    36   end
 | 
| 
bsw@1071
 | 
    37 
 | 
| 
bsw@1071
 | 
    38   -- If exactly one corresponding entry found, update the attributes
 | 
| 
bsw@1071
 | 
    39   local err = config.ldap.member.attr_map(ldap_entry, member)
 | 
| 
bsw@1071
 | 
    40   
 | 
| 
bsw@1074
 | 
    41   member.authority_uid = member.authority_uid or uid
 | 
| 
bsw@1074
 | 
    42   member.authority_login = config.ldap.member.login_map(ldap_entry)
 | 
| 
bsw@1071
 | 
    43   
 | 
| 
bsw@1071
 | 
    44   if err then
 | 
| 
bsw@1071
 | 
    45     return ldap_conn, ldap_entry, "attr_map_error", err
 | 
| 
bsw@1071
 | 
    46   end
 | 
| 
bsw@1071
 | 
    47   
 | 
| 
bsw@1071
 | 
    48   return ldap_conn, ldap_entry
 | 
| 
bsw@1071
 | 
    49     
 | 
| 
bsw@1071
 | 
    50 end
 |