Hi!
I'm trying to add a user in a user register via LDAP. The code below
works fine when I am testing it from a terminal.
But how do I do if I would like to do the same thing via Tomcat instead?
I've managed to create some services by using Java2wsdl2Java that only
confirms the connection.
Now I want to use the same tool, but I want the server to send the
request on to the user register. Where should I put this code to make it
work?
------------------------
import netscape.ldap.*;
import java.io.*;
import java.util.*;
public class add
{
public static void main(String args[])
{
/* define variables for the server and searching */
String host = "localhost";
int port = 389;
String dn = "Directory Manager";
String pwd = "password";
String new_dn = "uid=identifier, ou=C38, o=myCompany.com";
String objectclass_values [] = {"top", "person",
"organizationalperson", "inetorgperson"};
String cn_values [] = {"Bob Johnson"};
String sn_values [] = {"Johnson"};
String givenname_values [] = {"Bob"};
String ou_values [] = {"C38"};
String uid_values [] = {"bobby"};
String mail_values [] = {"[EMAIL PROTECTED]"};
LDAPAttributeSet attrib_set = null;
LDAPAttribute attribute = null;
LDAPEntry entry = null;
LDAPConnection ld = null;
try
{
ld = new LDAPConnection();
/* Must bind as a user with rights to write to the server */
ld.connect(host,port,dn,pwd);
attrib_set = new LDAPAttributeSet();
attribute = new LDAPAttribute("objectclass",objectclass_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("cn", cn_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("sn", sn_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("givenname", givenname_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("mail", mail_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("ou", ou_values);
attrib_set.add(attribute);
attribute = new LDAPAttribute("uid", uid_values);
attrib_set.add(attribute);
/* Create the entry object */
entry = new LDAPEntry(new_dn,attrib_set);
/* add the object */
ld.add(entry);
if (ld != null)
{
ld.disconnect();
}
}
catch(LDAPException e)
{
e.printStackTrace();
}
}
}
---------------------------------------
When I tried to put this code inside the implementation.java file I got
the following error;
-----------------------------------
Nov 6, 2002 3:54:25 PM org.apache.axis.client.Call invoke
INFO: Mapping Exception to AxisFault
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultString: (500)Internal Server Error
faultActor: null
faultDetail:
null: return code: 500
...
...
-----------------------------------------
So I guess that this wasn't the right place to put it.....
This how I wrote:
-----------------------------------------------
import netscape.ldap.*;
import java.io.*;
import java.util.*;
public class LdapTestImpl
{
//public static void main(String args[])
public String add( String testString )
{
System.out.println( "Inside Impl. String add() ");
/* define variables for the server and searching */
String host = "150.132.7.140";
int port = 389;
...
...
--------------------------------------------------
/ Emma