There is no direct java topic so I am telling here my problem:

I am writing an own java programm with NDK (com.novell.ldap.* packages)
and trying to use pagesize controls (cause I need an AD search query).
It doesn't work because it doesn't know the setServerControls method.
Does anybody have an idea how I can set the page size to get all
objects from AD (>1k)?

here is the code:


Code:
--------------------
LDAPControl[] pageControls = new LDAPControl[2];
// VLV requests also require a sort control; sort by common name
pageControls[0] = new LDAPSortControl(
new LDAPSortKey("samaccountname"), true);
// Do an initial search to get the virtual list size.
// Keep one page before and one page after the start.
beforeCount = pageSize;
afterCount = pageSize;
// selectedIndex = -1;
// // Create the initial VLV request control; we don't know the
// virtual list size, so we specify 0 for the size parameter

LDAPVirtualListControl vlc = new LDAPVirtualListControl(0, beforeCount,
afterCount, 0);
//doesn't find this method (cons is LDAPSearchConstraints)
cons.setServerControls(pageControls);
// Do a search
try {
String[] attrs = { "samaccountname" };
LDAPSearchResults result = lc.search(config.LDAPSEARCHBASE_AD,
searchScope, sF, attrs, false, cons);

// Check if we have a control returned
LDAPControl[] c = lc.getResponseControls();
if (c != null) {
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof LDAPVirtualListResponse) {
LDAPVirtualListResponse response = (LDAPVirtualListResponse) c[i];
selectedIndex = response.getFirstPosition() - 1;
top = Math.max(0, selectedIndex - beforeCount);
// Now we know the total size of the virtual
// list
size = response.getContentCount();
vlc.setListSize(size);
}
}
}
if (selectedIndex < 0) {
System.out.println("No VLV response control");
}
} catch (Exception ex) {
ex.printStackTrace();
}
--------------------


I read on a website that method setserverControls is inherited from
LdapConstraints. In the doc => Directory SDK 4.1 for Java API
Specification <= the method exists but maybe that is different because
it is netscape and not novell?

Thx for some help in advance!

Stephan from Germany


--
gaensss
------------------------------------------------------------------------
gaensss's Profile: http://forums.novell.com/member.php?userid=41326
View this thread: http://forums.novell.com/showthread.php?t=360096