diff options
author | Andrew Bartlett <abartlet@samba.org> | 2007-12-13 03:07:38 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:49:48 +0100 |
commit | 9d4d41f65dc8380d3c3ce19fceefbe3d00bd4e07 (patch) | |
tree | 180107521141a8c983378024810557b64155a9d9 /testprogs/ejs | |
parent | 1efd92e64e513ec0219e9d0ca28faec4bcb386c3 (diff) | |
download | samba-9d4d41f65dc8380d3c3ce19fceefbe3d00bd4e07.tar.gz samba-9d4d41f65dc8380d3c3ce19fceefbe3d00bd4e07.tar.bz2 samba-9d4d41f65dc8380d3c3ce19fceefbe3d00bd4e07.zip |
r26419: Add a module to implement 'ambigious name resolution' by munging the
incoming LDAP filter.
Warning: Any anr search will perform a full index search. Untill ldb
gets substring indexes, this is unavoidable.
Also implement a testsutie to show we match AD behaviour for this
important extension (used in the Active Directory Users and Computers
MMC plugin, as a genereral 'find').
This will also be useful to OpenChange, as their server needs to
implement this.
Andrew Bartlett
(This used to be commit 044b50947254ccd516c21cb156ab60ab9e3a582d)
Diffstat (limited to 'testprogs/ejs')
-rwxr-xr-x | testprogs/ejs/ldap.js | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/testprogs/ejs/ldap.js b/testprogs/ejs/ldap.js index 877240890d..7195b29e68 100755 --- a/testprogs/ejs/ldap.js +++ b/testprogs/ejs/ldap.js @@ -51,6 +51,8 @@ dn: cn=ldaptestuser,cn=uSers," + base_dn + " objectclass: user objectclass: person cN: LDAPtestUSER +givenname: ldap +sn: testy "); if (ok.error != 0) { ok = ldb.del("cn=ldaptestuser,cn=users," + base_dn); @@ -63,6 +65,8 @@ dn: cn=ldaptestuser,cn=uSers," + base_dn + " objectclass: user objectclass: person cN: LDAPtestUSER +givenname: ldap +sn: testy "); if (ok.error != 0) { println(ok.errstr); @@ -112,6 +116,7 @@ dn: cn=ldaptest2computer,cn=computers," + base_dn + " objectClass: computer cn: LDAPtest2COMPUTER userAccountControl: 4096 +displayname: ldap testy "); if (ok.error != 0) { ok = ldb.del("cn=ldaptest2computer,cn=computers," + base_dn); @@ -124,6 +129,7 @@ dn: cn=ldaptest2computer,cn=computers," + base_dn + " objectClass: computer cn: LDAPtest2COMPUTER userAccountControl: 4096 +displayname: ldap testy "); if (ok.error != 0) { println(ok.errstr); @@ -151,6 +157,8 @@ dn: cn=ldaptestuser2,cn=useRs," + base_dn + " objectClass: person objectClass: user cn: LDAPtestUSER2 +givenname: testy +sn: ldap user2 "); if (ok.error != 0) { ok = ldb.del("cn=ldaptestuser2,cn=users," + base_dn); @@ -163,6 +171,8 @@ dn: cn=ldaptestuser2,cn=useRs," + base_dn + " objectClass: person objectClass: user cn: LDAPtestUSER2 +givenname: testy +sn: ldap user2 "); if (ok.error != 0) { println(ok.errstr); @@ -170,6 +180,136 @@ cn: LDAPtestUSER2 } } + + println("Testing Ambigious Name Resolution"); + println("Testing ldb.search for (&(anr=ldap testy)(objectClass=user))"); + var res = ldb.search("(&(anr=ldap testy)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 3) { + println("Could not find (&(anr=ldap testy)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 3); + } + + println("Testing ldb.search for (&(anr=testy ldap)(objectClass=user))"); + var res = ldb.search("(&(anr=testy ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 2) { + println("Could not find (&(anr=testy ldap)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 2); + } + + println("Testing ldb.search for (&(anr=ldap)(objectClass=user))"); + var res = ldb.search("(&(anr=ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 4) { + println("Found only " + res.msgs.length + " for (&(anr=ldap)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 4); + } + + println("Testing ldb.search for (&(anr==ldap)(objectClass=user))"); + var res = ldb.search("(&(anr==ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr==ldap)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser"); + assert(res.msgs[0].name == "ldaptestuser"); + + println("Testing ldb.search for (&(anr=testy)(objectClass=user))"); + var res = ldb.search("(&(anr=testy)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 2) { + println("Could not find (&(anr=testy)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 2); + } + + println("Testing ldb.search for (&(anr=ldap testy)(objectClass=user))"); + var res = ldb.search("(&(anr=testy ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 2) { + println("Could not find (&(anr=ldap testy)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 2); + } + + println("Testing ldb.search for (&(anr==ldap testy)(objectClass=user))"); + var res = ldb.search("(&(anr==testy ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr==ldap testy)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser"); + assert(res.msgs[0].name == "ldaptestuser"); + + println("Testing ldb.search for (&(anr==testy ldap)(objectClass=user))"); + var res = ldb.search("(&(anr==testy ldap)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr==testy ldap)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser"); + assert(res.msgs[0].name == "ldaptestuser"); + + println("Testing ldb.search for (&(anr=testy ldap user)(objectClass=user))"); + var res = ldb.search("(&(anr=testy ldap user)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr=testy ldap user)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser2,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser2"); + assert(res.msgs[0].name == "ldaptestuser2"); + + println("Testing ldb.search for (&(anr==testy ldap user2)(objectClass=user))"); + var res = ldb.search("(&(anr==testy ldap user2)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr==testy ldap user2)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser2,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser2"); + assert(res.msgs[0].name == "ldaptestuser2"); + + println("Testing ldb.search for (&(anr==ldap user2)(objectClass=user))"); + var res = ldb.search("(&(anr==ldap user2)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(anr==ldap user2)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + assert(res.msgs[0].dn == ("CN=ldaptestuser2,CN=Users," + base_dn)); + assert(res.msgs[0].cn == "ldaptestuser2"); + assert(res.msgs[0].name == "ldaptestuser2"); + + println("Testing ldb.search for (&(anr==not ldap user2)(objectClass=user))"); + var res = ldb.search("(&(anr==not ldap user2)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 0) { + println("Must not find (&(anr==not ldap user2)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 0); + } + + println("Testing ldb.search for (&(anr=not ldap user2)(objectClass=user))"); + var res = ldb.search("(&(anr=not ldap user2)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 0) { + println("Must not find (&(anr=not ldap user2)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 0); + } + println("Testing Group Modifies"); ok = ldb.modify(" dn: cn=ldaptestgroup,cn=users," + base_dn + " @@ -884,6 +1024,20 @@ member: CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn + " assert(ok.error == 0); } + println("Testing ldb.search for (&(cn=ldaptestutf8user2*)(objectClass=user))"); + var res = ldb.search("(&(cn=ldaptestutf8user2*)(objectClass=user))"); + if (res.error != 0 || res.msgs.length != 1) { + println("Could not find (&(cn=ldaptestutf8user2*)(objectClass=user))"); + assert(res.error == 0); + assert(res.msgs.length == 1); + } + + ok = ldb.del(res.msgs[0].dn); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + ok = ldb.del(("CN=ldaptestgroup2,CN=Users," + base_dn)) if (ok.error != 0) { println(ok.errstr); |