ABSTRACT:
After submitting changes to LDAP server properties, how do you refresh the server programmatically to update the values?
DETAILED DESCRIPTION
How can you programatically call the function that is equivalant to "Refresh NLDAP Server" in NWADMIN and in ConsoleOne using Java?
/***************************************************************************
public static int notifyNldapServerToRefresh(JFrame parentFrame, String treeName, String hostServerDN) { if (hostServerDN == null || hostServerDN.length() == 0) { return -1; } String ncpServer = treeName + "/" + hostServerDN;
try { Hashtable hash = new Hashtable(); hash.put("java.naming.factory.initial", "com.novell.service.nds.naming.NdsInitialContextFactory"); hash.put("java.naming.provider.url", ncpServer);
Context ctx = new InitialContext(hash); Context ncpServerCtx = (Context)ctx.lookup("/");
Context ctx2; try { ctx2 = (Context)ncpServerCtx.lookup("NCPExtensions"); } catch (javax.naming.NameNotFoundException exp1) { // send error message here return -1; }
NCPExtensionDirContext ctx3; try { ctx3 = (NCPExtensionDirContext)ctx2.lookup("NLDAP"); } catch (javax.naming.NameNotFoundException exp2) { // Cannot find NLDAP // send error message here return -1; } byte[] data = new byte[0]; byte[] response = ctx3.send(data, 200); // 200: maximum reply length } catch (Exception exp) { // send error message here } return 0; } // notifyNldapServerToRefresh
--devsup
© 2009 Novell, Inc. All Rights Reserved.