Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
UTF8 and Net_LDAP2:
2
 
3
It is hard to know exactly what entries need utf8 every time you need them,
4
so here's the simple way to salvation:
5
 
6
Net_LDAP2 will check internally if utf8 is needed.
7
 
8
Code:
9
      // $attr is some text a user entered with funny characters in it.
10
      // If $attr should not be utfized (f.x. userPassword) then utf8Encode
11
      // will not encode the attribute.
12
      $attr = $ldap->utf8Encode($attr);
13
      // now insert the correctly encoded attribute  into the directory.
14
      $entry->modify($attr);
15
 
16
      // later when you access the attributes of that user, decode the ones
17
      // that have to be decoded.
18
      $attr = $ldap->utf8Decode( $entry->attributes() );
19
 
20
Thanks to Jan for the code.