dsimportexport is broken # 2

So there's another thing broken with dsimportexport apart from not overwriting properly.

If you are importing users, and you're not specifying the uid value, Workgroup Manager picks quite a sane value for the uid for that user.

dsimportexport on the other hand, seems to just pick really huge numbers that have no relation to reality, so you need to construct this manually.

In php, I'm doing it with something like this:

function get_next_uid()
{
        $nextuid_conn = ldap_connect("my.od.master.server");
        ldap_set_option($nextuid_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
        ldap_start_tls($nextuid_conn);
        $nextuid_bind = ldap_bind($nextuid_conn);
        if (! $nextuid_bind) { return false; }

        $nextuid_search = ldap_search($nextuid_conn,  "cn=users,dc=myorg,dc=au "(uid=*)", array ("uid","uidnumber"));
        $nextuid_info = ldap_get_entries($nextuid_conn, $nextuid_search);
        $current_uids = array();
        foreach ($nextuid_info as $this_nextuid)
        {
                $current_uids[] = $this_nextuid[uidnumber][0];
        }
        sort($current_uids);
        $the_next_uid = ( array_pop($current_uids) + 1);
        return $the_next_uid;
}

So when you're importing a bunch of users, call this to work out the next available uid.

Leave a Reply

Name and Email Address are required fields. Your email will not be published or shared with third parties.