Novell Home

TID102188 (xjclsp01) How to Refresh the LDAP Server

From Developer Community

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?

/***************************************************************************

  • Method: notifyNldapServerToRefresh
  • Input:
  • String treeName; // i.e., NOVELL_INC
  • String hostServerDN; // Could be null or empty
  • Output:
  • 0 = success, -1 = failure
                                                                                                                                                    • /

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

Novell® Making IT Work As One

© 2009 Novell, Inc. All Rights Reserved.