Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = 'cn=opendcim bind,ou=opendcim,ou=Applications,ou=Services,dc=domain,dc=com';
- $password = 'test';
- $server = 'domain.com';
- $ldapConn = ldap_connect($server);
- if (!$ldapConn) {
- exit('Connection failed');
- }
- // Help talking to AD
- ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($ldapConn, LDAP_OPT_REFERRALS, 0);
- $ldapBind = ldap_bind($ldapConn, $username, $password);
- if (!$ldapBind) {
- exit("\nBinding failed\n\n");
- }
- printf("\nHello from LDAP\n\n");
- //$filter = "(&(objectClass=group)(member=CN=Luis Caldeira,OU=Ent Admins,OU=Services,DC=domain,DC=com))";
- $filter = "(&(userprincipalname=user@domain.com)(memberOf:1.2.840.113556.1.4.1941:=cn=siteAdmin,ou=opendcim,ou=Applications,ou=Services,dc=domain,dc=com))";
- $search = ldap_search($ldapConn,"DC=domain,DC=com",$filter);
- $results = ldap_get_entries($ldapConn,$search);
- var_dump($results);
- // This is where you can do your work
- ldap_close($ldapConn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement