OK....I'm making a little progress with this....but not much. I'll show what I've got and see if anyone has suggestions.
I took some ideas from some of the sample zimlets...specifically jspsample and compose_mail_example. I've got two files in my zimlet... edu_wiu_email_starnum.xml, and ldap.jsp.
edu_wiu_email_starnum.xml
Code:
<zimlet name="edu_wiu_email_starnum" version="1.0" description="EmailStarnum">
<userProperties>
<property type="string" name="uname" label="Username"/>
<property type="string" name="pass" label="Password"/>
<property type="string" name="url" label="Page URL"/>
<property type="enum" name="dlstyle" label="Download Style">
<item label="Attachments Only" visualType="radio"/>
<item label="Body Only" visualType="radio"/>
</property>
</userProperties>
<zimletPanelItem label="EmailStarnum">
<toolTipText>
Drag'n'Drop a message or folder here to send props to the JSP
</toolTipText>
<dragSource type="ZmMailMsg">
<canvas type="dialog" width="600" height="350"/>
<actionUrl target="/service/zimlet/_dev/edu_wiu_email_starnum/ldap.jsp">
<param name="subject">${obj.subject}</param>
<param name="id">${obj.id}</param>
</actionUrl>
</dragSource>
<dragSource type="ZmConv">
<canvas type="dialog" width="600" height="350"/>
<actionUrl target="/service/zimlet/_dev/edu_wiu_email_starnum/ldap.jsp">
<param name="subject">${obj.subject}</param>
<param name="id">${obj.id}</param>
</actionUrl>
</dragSource>
<dragSource type="ZmFolder">
<canvas type="dialog" width="600" height="350"/>
<actionUrl target="/service/zimlet/_dev/edu_wiu_email_starnum/ldap.jsp">
<param name="name">${obj.name}</param>
<param name="path">${obj.path}</param>
</actionUrl>
</dragSource>
</zimletPanelItem>
</zimlet> The params passed to the ldap.jsp are ignored for now, all I try to do is return results to the popup window.
ldap.jsp
Code:
<%@ page language="java" import="com.sun.jndi.ldap.*, java.io.*, java.util.*, javax.naming.*, javax.naming.directory.*"%>
<%
String ldapServerName = "ldap";
String user = "AUTHUSER";
String pass = "AUTHPASS";
String dn= "uid=" . concat(user) . concat(",ou=blahblahblah");
String rootContext = "ou=" . concat(user);
Properties env = new Properties();
env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.LdapCtxFactory" );
env.put("java.naming.ldap.version", "3");
env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName + "/");
env.put( Context.SECURITY_AUTHENTICATION, "simple");
env.put( Context.SECURITY_PRINCIPAL, dn );
env.put( Context.SECURITY_CREDENTIALS, pass);
try {
//Create the initial directory context
DirContext ctx = new InitialDirContext( env);
//Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("uid=USERNAME,ou=blahblahblah");
//Find the surname attribute ("sn") and print it
//System.out.println("sn: "+ attrs.get("sn").get());
}
catch (NamingException e){
//Authentication Failed
}
PrintWriter pw = response.getWriter();
pw.println("sn: "+ attrs.get("sn").get());
%> This works in the compose_email_example zimlet, but here where I try to do the same thing, the window pops up with errors in it...
HTTP ERROR: 500
PWC6033: Unable to compile class for JSP
PWC6197: An error occurred at line: 19 in the jsp file: /zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
PWC6199: Generated servlet error:
PrintWriter cannot be resolved to a type
RequestURI=/service/zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
Can anyone help me resolve this?
Eventually I want to add a .js file that opens a new compose window, and I think I have that part figured out, but I need to know if I can even get this LDAP Query JSP to work first.
Thanks,
Matt