After some serious googling and some failed attempts here and there, I have been able to create a java service that does exactly what I want. Of course all the standard lawyer speak applies, plus I want to ba able to pass the connection Key instead of logging in (Kind of like what is done in WmPublic, but that is the next step that I am working on, and I need to figure that out.
I am NOT a Java coder so it ain’t pretty. The following is from the “source” directory under my package called ActiveDirectory
package ActiveDirectory;
// -----( IS Java Code Template v1.2
// -----( CREATED: 2005-05-11 14:20:35 CDT
// -----( ON-HOST: xxxx.xxx.com
import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
// --- <> ---
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
// --- <> ---
public final class javaServices
{
// ---( internal utility methods )---
final static javaServices _instance = new javaServices();
static javaServices _newInstance() { return new javaServices(); }
static javaServices _cast(Object o) { return (javaServices)o; }
// ---( server methods )---
public static final void renameDN (IData pipeline)
throws ServiceException
{
// --- <> ---
// @subtype unknown
// @sigtype java 3.5
// [i] field:0:required fromDN
// [i] field:0:required targetDN
// [i] field:0:required ldapURL
// [i] field:0:required ldapUser
// [i] field:0:required ldapPass
// [o] field:0:required targetDN
// [o] field:0:required Error
//pipeline
IDataCursor idcPipeline = pipeline.getCursor();
String strFromDN = "";
String strTargetDN = "";
String strLdapURL = "";
String strLdapUser = "";
String strLdapPass = "";
String strError = "";
if (idcPipeline.first("fromDN"))
strFromDN = (String)idcPipeline.getValue(); // full path - CN=name,OU=Somewhere,DC=YourCompany,DC=com
if (idcPipeline.first("targetDN"))
strTargetDN = (String)idcPipeline.getValue(); // full path - CN=name,OU=Somewhere,DC=YourCompany,DC=com
if (idcPipeline.first("ldapURL"))
strLdapURL = (String)idcPipeline.getValue(); // ldap://servername:389
if (idcPipeline.first("ldapUser"))
strLdapUser = (String)idcPipeline.getValue(); // Admin user
if (idcPipeline.first("ldapPass"))
strLdapPass = (String)idcPipeline.getValue(); // password
// Set up environment for creating initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, strLdapURL);
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL, strLdapUser);
env.put(Context.SECURITY_CREDENTIALS, strLdapPass);
try {
// Create initial context
DirContext ctx = new InitialDirContext(env);
// Perform rename rename
ctx.rename(strFromDN, strTargetDN);
// This does not yet work so well
System.out.println(ctx.lookup(strTargetDN));
// Close the context
ctx.close();
// Surely there will not be errors, but I'll catch them anyway
}
catch(Exception ex)
{
System.out.println(ex);
strError = ex.toString();
}
// pipeline
IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( "targetDN", strTargetDN );
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( "Error", strError);
pipelineCursor_1.destroy();
// --- <> ---
}
}
#Adapters-and-E-Standards#webMethods#Integration-Server-and-ESB