Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String host = "*****";
- int port = 389;
- String authid = "*****";
- String authpw = "*****";
- String[] ATTR = {*****};
- String[] ATTR1 = {*****};
- String base = "*****";
- LDAPConnection ld = null;
- LDAPSearchResults searchResult;
- int numSubord = 0;
- int index = 0;
- long totalTime = 0;
- long startTime = 0;
- int iter = 1;
- for (int i = 0; i < iter; i++) {
- startTime = System.currentTimeMillis();
- try {
- ld = new LDAPConnection();
- ld.connect(3, host, port, authid, authpw);
- searchResult = ld.search(base, LDAPConnection.SCOPE_BASE, "(objectclass=*)", ATTR1, false);
- if (searchResult.getCount() == 0) {
- return;
- }
- LDAPEntry en = searchResult.next();
- numSubord = Integer.parseInt(en.getAttribute(ATTR1[0]).getStringValueArray()[0]);
- index = numSubord - 4;
- if (index < 1) {
- index = 1;
- }
- searchResult = ld.search(base, LDAPConnection.SCOPE_ONE, "(&(index>=" + index + ")(index<=" + numSubord + "))", ATTR, false);
- } catch (LDAPException e) {
- }
- try {
- if (ld != null) {
- ld.disconnect();
- }
- } catch (LDAPException ex) {
- }
- totalTime += System.currentTimeMillis() - startTime;
- }
- System.out.println(totalTime / iter);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement