forked from beaulebens/hCard-LDAP-Service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
connect.php
63 lines (53 loc) · 1.85 KB
/
connect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
$ldap = ldap_connect( 'ldap://twitfave.com/' );
if ( $ldap ) {
$bind = ldap_bind( $ldap, 'cn=admin,dc=nodomain', 'mfslapd%%' );
if ( !$bind ) {
echo 'Failed to connect to LDAP server!';
exit;
}
$dn = 'uid=1,dc=1234,dc=nodomain';
$entry = array();
$entry['objectClass'] = array( 'top', 'person', 'organizationalPerson', 'inetOrgPerson', 'hCard' );
$entry['cn'] = array( 'Stephen Weber' ); // Common Name
$entry['sn'] = array( 'Weber' ); // Surname/Family Name
$entry['gn'] = array( 'Stephen' ); // Given Name
$entry['displayName'] = array( 'singpolyma' ); // Nickname
// $entry['title'] = array( '' ); // Job role
$entry['mail'] = array( 'singpolyma@singpolyma.net' ); // Email
$entry['labeledURI'] = array( 'http://singpolyma.net' );
$entry['mobile'] = array( '+16503957464' ); // Mobile number
// $entry['telephoneNumber'] = array( '+14156916235' ); // Phone number
// $entry['postalAddress'] = array( '1408 California St, #301
// San Francisco, CA' ); // Mailing address, preformatted (homePostalAddress)
// $entry['postalCode'] = array( '94109' ); // ZIP
if ( !ldap_add( $ldap, $dn, $entry ) ) {
echo ldap_error( $ldap );
} else {
echo 'Successfully added entry';
}
ldap_close( $ldap );
}
/*
Add these from hCard/vCard
additionalName
personalTitle
honorificSuffix
bday
tz
sourceURI
NOTES:
Install OpenLDAP
Configure top-level dc (service name)
Add in dc=addressbook
Add our objectClass (hCard)
---
objectclass ( <NUMBER> NAME 'vCardPerson' SUP inetOrgPerson STRUCTURAL
MAY ( additionalName $ personalTitle $ honorificSuffix $ bday $ tz $ sourceURI ) )
---
Can't add multiple physical addresses
Resolve different phone numbers against unique attributes
Photo/Avatar? jpegPhoto | photo?
Checkbox for get XFN crawl from sourceURI
function hcard2ldap()
*/