env.put(Context.REFERRAL, "follow");
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
DirContext context = new InitialDirContext(env);
final MockLdapServer referralServer = new MockLdapServer();
referralServer.start();
ASN1Encodable ref = new ASN1Encodable() {
public void encodeValues(Object[] values) {
List<byte[]> list = new ArrayList<byte[]>();
list.add(Utils.getBytes(referralServer.getURL()));
values[0] = list;
}
};
server.setResponseSeq(new LdapMessage[] {
new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_REF, ref,
null),
new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
referralServer.setResponseSeq(new LdapMessage[] {
new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
new BindResponse(), null),
new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });