Migrated from the original repository at http://smalltalkhub.com/#!/~PharoExtras/LDAP/
LDAP (Lightweight Directory Access Protocol) is a network protocol that allows the communication between Pharo and entreprise directories. LDAP is mainly used for authentication of users into the mails servers, enterprise applications or biometric systems. This implementation is fully written in Pharo and don't requires access to native libraries.
Metacello new
configuration: 'LDAP';
repository: 'github://pharo-contributions/LDAP/src';
version: #stable;
load.
| conn req |
[ conn := (LDAPSConnection to: 'sldap123.someuri.org' port: 686 ssl: true).
req := conn bindAs: 'uid=myuid,ou=people,o=someuri,c=org' credentials: '123'.
req wait.
conn isValid ] on: Error do: [ 1 halt ]
conn := (LDAPConnection to: 'ldap.domain.org' port: 389).
req := conn bindAs: 'cn=admin,dc=domain,dc=org' credentials: 'password'.
req wait.
attrs := Dictionary new
at: 'objectClass' put: (OrderedCollection new add: 'inetOrgPerson'; yourself);
at: 'cn' put: 'Doe John';
at: 'sn' put: 'Doe';
at: 'mail' put: '[email protected]';
yourself.
req := conn addEntry: 'jdoe' attrs: attrs.
req wait.
ops := { LDAPAttrModifier set: 'sn' to: { 'Doe' } }.
req := conn modify: 'uid=jdoe,ou=people,dc=domain,dc=org' with: ops.
req wait.
ops := { LDAPAttrModifier addTo: 'loginShell' values: { '/bin/bash' } }.
req := conn modify: 'uid=jdoe,ou=people,dc=domain,dc=org' with: ops.
req wait.
req := conn
newSearch: 'ou=people,dc=domain,dc=org'
scope: (LDAPConnection wholeSubtree)
deref: (LDAPConnection derefNever)
filter: nil
attrs: nil
wantAttrsOnly: false.
req := conn
newSearch: 'ou=people,dc=domain,dc=org'
scope: LDAPConnection wholeSubtree
deref: LDAPConnection derefNever
filter: (LDAPFilter andOf: (OrderedCollection new
add: (LDAPFilter with: 'sn' equalTo: 'Doe');
yourself))
attrs: {'sn'}
wantAttrsOnly: false.
req wait.
req := connection delEntry: 'uid=doe,ou=people,dc=domain,dc=org'.
req wait.
conn disconnect