[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zimlets and LDAP



That info got me started...

http://www.zimbra.com/forums/zimlets/23565-querying-ldap-zimlet.html#post112900

I've done a little work on this and posted what I have so far in the forums.

Thanks,
Matt


----- Original Message -----
From: "Robert M. Thompson" <ab5602@wayne.edu>
To: "zimbra-hied-admins" <zimbra-hied-admins@sfu.ca>
Sent: Wednesday, October 22, 2008 6:55:50 AM GMT -06:00 US/Canada Central
Subject: Re: Zimlets and LDAP


Yup, John is right.  At some point in the code, you're going to need the Javascript in the Zimlet to call a server-side script via HTTP.  You've really only got 2 choices here, since Javascript does not have any built-in LDAP classes:

 1) Call a .jsp, packaged with your Zimlet, to do your LDAP calls
 2) Use Zimbra's built-in proxy service to call any URL you want

The Zimbra server will proxy your HTTP request from the client, through to any other server.  This is necessary as browsers won't allow you to call external pages in Javascript directly.  I find #2 more convenient as I'm more practiced in PHP than I am in Java =).  However, if you want to go with #1, the following code may be a good start.  It is some JAVA LDAP authentication code pulled from our preauth script:

-Rob

------

 <%@ page import="javax.naming.*" %>
 <%@ page import="com.sun.jndi.ldap.*" %>

 <%
 ...
 ...
 String ldapServerName = "directory.your.edu";         

 String user = "myusername";
 String pass = "mypass";    
        
 String dn = "uid=" . concat(user) . concat(",ou=People,dc=your,dc=edu");
 String rootContext = "ou=".concat(user);
                  
 Properties env = new Properties();
                   
 env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.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 {
     DirContext ctx = new InitialDirContext( env );
     // Authenticated
     }
 catch (NamingException e) 
     { 
     // Authentication Failed
     }
 %>

-- 
Rob Thompson, Systems Analyst
Enterprise Applications
Computing & Information Technology
Wayne State University
313-577-5645

Public Key: http://pgp.wayne.edu/rob.key


----- "John Holder" <jholder@zimbra.com> wrote:

> Try using the classes that we use in Zimbra is your jsps
> 
> http://java.sun.com/products/jndi/tutorial/
> 
> You cannot use a get call to get ldap data, unless the jsp translates
> it on the back end to a good oldfashion ldap call.
> 
> for example
> 
> http://server.com/service/zimlet/com_zimbra_ldapquery/query.jsp?classname=edu101&studentid=5711
> 
> would use jndi on the back end to talk to what ever ldap server you
> want.
> 
> This is the extent of my knowledge on the subject, but thought it
> might be helpful
> 
> John
> 
> 
> ----- Original Message -----
> From: "Matt Mencel" <MR-Mencel@wiu.edu>
> To: "zimbra-hied-admins" <zimbra-hied-admins@sfu.ca>
> Sent: Tuesday, October 21, 2008 8:43:57 PM GMT -07:00 U.S. Mountain
> Time (Arizona)
> Subject: Re: Zimlets and LDAP
> 
> It doesn't directly query your LDAP server from the Zimlet though does
> it? The page you make the HTTP GET call too does the LDAP query?
> 
> I'm trying to figure out how to make the LDAP query from the
> Zimlet....
> 
> Thanks,
> Matt
> 
> 
> ----- Original Message -----
> From: "Robert M. Thompson" <ab5602@wayne.edu>
> To: "zimbra-hied-admins" <zimbra-hied-admins@sfu.ca>
> Sent: Tuesday, October 21, 2008 8:49:16 PM GMT -06:00 US/Canada
> Central
> Subject: Re: Zimlets and LDAP
> 
> 
> Yup, we've developed one. It calls a page w/ an HTTP GET, and displays
> the results in a popup when you hover over a REGEX match. Let me know
> if you would like the code.
> 
> -Rob
> 
> --
> Rob Thompson, Systems Analyst
> Enterprise Applications
> Computing & Information Technology
> Wayne State University
> 313-577-5645
> 
> Public Key: http://pgp.wayne.edu/rob.key
> 
> 
> ----- "Matt Mencel" <MR-Mencel@wiu.edu> wrote:
> 
> > Just curious if anyone is writing their own Zimlets yet that query
> > your internal LDAP directories. I'm stuck on that problem here...
> >
> > Thanks,
> > Matt Mencel
> > Western Illinois University