20090416 doing dsml with sun directory - plembo/onemoretech GitHub Wiki

title: Doing DSML with Sun Directory link: https://onemoretech.wordpress.com/2009/04/16/doing-dsml-with-sun-directory/ author: lembobro description: post_id: 338 created: 2009/04/16 16:23:11 created_gmt: 2009/04/16 16:23:11 comment_status: open post_name: doing-dsml-with-sun-directory status: publish post_type: post

Doing DSML with Sun Directory

One of my colleagues overseas recently lamented that what we really need in our (corporate) environment is a web service to interact with LDAP directory data using XML.

Of course most directory servers today have something to do that. Sun’s Java Systems Directory Server 5.2 comes with an integrated DSML server. Setting it up is pretty easy. All you have to do is go into the Server Console, open up your source instance and click on the Configuration… Network tab and check off the “Enable DSML” box. Then select what kinds of ports you’ll be using (secure, non-secure or both) and the port numbers (be sure to check to make sure whatever you choose is not already in use for something else). Do a save and you’re in business.

Now to test it. Being new to DSML, and XML in general, I needed something really simple. It turned out that, at least for now, Net::DSML fit the bill. Unfortunately the example code given in the documentation is replete with syntax errors and missing or mis-named variables, so I had to rewrite things a bit to get working.

Here’s a complete script that will query the DSE Root (note that you’ll need to replace “ldap.example.com” and the HTTP listening port with the actual values for your environment).

`

#! /usr/bin/perl
use Net::DSML;
use Net::DSML::Filter;
$dirHost = "ldap.example.com";
$dsmlPort = "11000";
$dsml = Net::DSML->new({ debug => 0,
                         url => "http://$dirHost:$dsmlPort/dsml" });
if (!$dsml->rootDSE( { attributes => @attributes } )) {
	
    print $dsml->error, "n";
    exit;
}
if ( !$dsml->send() ) {
	
    print $dsml->error, "n";
    exit;
}
$content = $dsml->content(); # Get data returned from the DSML server.
print $content, "n";
__END__;

`

Copyright 2004-2019 Phil Lembo