Hammond, Steven wrote:
This is how I did it back in 1.5.3 (which I am still on until we get budget to 
move to the present)

A warning, at first I just had getAddress, but this caused a reverseDNS lookup 
and noticeable slowness.

In core\src\main\java\org\apache\directory\server\core\jndi\ServerContext.java  
I added  client_host and client_port:


    protected NamingEnumeration<ServerSearchResult> doSearchOperation( LdapDN 
dn, AliasDerefMode aliasDerefMode,
        ExprNode filter, SearchControls searchControls, InetSocketAddress 
clientAddress,
        DirContext dirCtx) throws NamingException
    {
        // setup the op context and populate with request controls
        SearchOperationContext opCtx = new SearchOperationContext( registries, 
dn, aliasDerefMode, filter,
            searchControls );

        opCtx.put( "client_host", clientAddress.getAddress().getHostAddress() );
        opCtx.put( "client_port", String.valueOf( clientAddress.getPort() ) );
        opCtx.put( "client_JNDI_CXN", dirCtx );
        opCtx.addRequestControls( requestControls );

        // execute search operation
        NamingEnumeration<ServerSearchResult> results = nexusProxy.search( 
opCtx );

// clear the request controls and set the response controls requestControls = EMPTY_CONTROLS;
        responseControls = opCtx.getResponseControls();

        return results;
    }



Then in the my partition inside    public NamingEnumeration<ServerSearchResult> 
search(SearchOperationContext arg0) I have:

            ob = opContext.get("client_host");
            if (ob != null)
            {
               String hostname = (String) ob;
               ob = opContext.get("client_port");
               String clientPort = (String) ob;


Thanks for letting me know your approach. It looks like thngs have changed a lot since then, the SearchOperationContext doesn't have a put method. It seems that with Apache DS a minor point release means a big internal code change. :)

My approach has worked *OK* ... but it's not passing the connections details down to the authentication layer so I can use it in the bind operation. I'll need to dig further to see if I can get this working. I'll update the Jira issue as I progress.

Matt


Reply via email to