Getting information from the LDAP server | Zend_Ldap Programmer's Reference Guide | Zend_Loader

# Serializing LDAP data to and from LDIF

# Serialize a LDAP entry to LDIF

1. $data = array (
2. 'dn' => 'uid=rogasawara,ou=営業部,o=Airius',
3. 'objectclass' => array ('top',
4. 'person',
5. 'organizationalPerson',
6. 'inetOrgPerson'),
7. 'uid' => array ('rogasawara'),
8. 'mail' => array ('rogasawara@airius.co.jp'),
9. 'givenname;lang-ja' => array ('ロドニー'),
10. 'sn;lang-ja' => array ('小笠原'),
11. 'cn;lang-ja' => array ('小笠原 ロドニー'),
12. 'title;lang-ja' => array ('営業部 部長'),
13. 'preferredlanguage' => array ('ja'),
14. 'givenname' => array ('ロドニー'),
15. 'sn' => array ('小笠原'),
16. 'cn' => array ('小笠原 ロドニー'),
17. 'title' => array ('営業部 部長'),
18. 'givenname;lang-ja;phonetic' => array ('ろどにー'),
19. 'sn;lang-ja;phonetic' => array ('おがさわら'),
20. 'cn;lang-ja;phonetic' => array ('おがさわら ろどにー'),
21. 'title;lang-ja;phonetic' => array ('えいぎょうぶ ぶちょう'),
22. 'givenname;lang-en' => array ('Rodney'),
23. 'sn;lang-en' => array ('Ogasawara'),
24. 'cn;lang-en' => array ('Rodney Ogasawara'),
25. 'title;lang-en' => array ('Sales, Director'),
26. );
27. $ldif = Zend_Ldap_Ldif_Encoder::encode($data, array ('sort' => false,
28. 'version' => null));
29. /*
30. $ldif contains:
31. dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz
32. objectclass: top
33. objectclass: person
34. objectclass: organizationalPerson
35. objectclass: inetOrgPerson
36. uid: rogasawara
37. mail: rogasawara@airius.co.jp
38. givenname;lang-ja:: 44Ot44OJ44OL44O8
39. sn;lang-ja:: 5bCP56yg5Y6f
40. cn;lang-ja:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
41. title;lang-ja:: 5Za25qWt6YOoIOmDqOmVtw==
42. preferredlanguage: ja
43. givenname:: 44Ot44OJ44OL44O8
44. sn:: 5bCP56yg5Y6f
45. cn:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
46. title:: 5Za25qWt6YOoIOmDqOmVtw==
47. givenname;lang-ja;phonetic:: 44KN44Gp44Gr44O8
48. sn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJ
49. cn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJIOOCjeOBqeOBq+ODvA==
50. title;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2IOOBtuOBoeOCh+OBhg==
51. givenname;lang-en: Rodney
52. sn;lang-en: Ogasawara
53. cn;lang-en: Rodney Ogasawara
54. title;lang-en: Sales, Director
55. */

# Deserialize a LDIF string into a LDAP entry

1. $ldif = "dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz
2. objectclass: top
3. objectclass: person
4. objectclass: organizationalPerson
5. objectclass: inetOrgPerson
6. uid: rogasawara
7. mail: rogasawara@airius.co.jp
8. givenname;lang-ja:: 44Ot44OJ44OL44O8
9. sn;lang-ja:: 5bCP56yg5Y6f
10. cn;lang-ja:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
11. title;lang-ja:: 5Za25qWt6YOoIOmDqOmVtw==
12. preferredlanguage: ja
13. givenname:: 44Ot44OJ44OL44O8
14. sn:: 5bCP56yg5Y6f
15. cn:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
16. title:: 5Za25qWt6YOoIOmDqOmVtw==
17. givenname;lang-ja;phonetic:: 44KN44Gp44Gr44O8
18. sn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJ
19. cn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJIOOCjeOBqeOBq+ODvA==
20. title;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2IOOBtuOBoeOCh+OBhg==
21. givenname;lang-en: Rodney
22. sn;lang-en: Ogasawara
23. cn;lang-en: Rodney Ogasawara
24. title;lang-en: Sales, Director";
25. $data = Zend_Ldap_Ldif_Encoder::decode($ldif);
26. /*
27. $data = array(
28. 'dn' => 'uid=rogasawara,ou=営業部,o=Airius',
29. 'objectclass' => array('top',
30. 'person',
31. 'organizationalPerson',
32. 'inetOrgPerson'),
33. 'uid' => array('rogasawara'),
34. 'mail' => array('rogasawara@airius.co.jp'),
35. 'givenname;lang-ja' => array('ロドニー'),
36. 'sn;lang-ja' => array('小笠原'),
37. 'cn;lang-ja' => array('小笠原 ロドニー'),
38. 'title;lang-ja' => array('営業部 部長'),
39. 'preferredlanguage' => array('ja'),
40. 'givenname' => array('ロドニー'),
41. 'sn' => array('小笠原'),
42. 'cn' => array('小笠原 ロドニー'),
43. 'title' => array('営業部 部長'),
44. 'givenname;lang-ja;phonetic' => array('ろどにー'),
45. 'sn;lang-ja;phonetic' => array('おがさわら'),
46. 'cn;lang-ja;phonetic' => array('おがさわら ろどにー'),
47. 'title;lang-ja;phonetic' => array('えいぎょうぶ ぶちょう'),
48. 'givenname;lang-en' => array('Rodney'),
49. 'sn;lang-en' => array('Ogasawara'),
50. 'cn;lang-en' => array('Rodney Ogasawara'),
51. 'title;lang-en' => array('Sales, Director'),
52. );
53. */

Getting information from the LDAP server | Zend_Ldap Programmer's Reference Guide | Zend_Loader