Ldap4pl updated for utf-8 compatibility (help needed: testing)

Hello,

I updated ldap4pl to work correctly with UTF-8 (at least on Windows, don’t know whether there were problems on linux, where I think UTF-8 is the internal encoding).

Anyone willing to test (especially on non-windows platforms) is very welcome. (So far I only tested searching, no writes [on production ActiveDirectory …])

It should build without problems at least on MSYS2 x64, but since the changes are minimal, I’d expect it should work on other platforms.

(so far, i neglected updating any package info etc.).

the repository is available at: https://github.com/nuclear-ares/ldap4pl

?- pack_install('git://github.com/nuclear-ares/ldap4pl.git').

testing script (ldtest.pl):

:- module(ldtest, [search/0]).

:- use_module(library(ldap4pl)).
:- use_module(library(ldap4pl_util)).

search :-
    ldap_initialize(LDAP, 'ldap://ldap.forumsys.com'),
    ldap_set_option(LDAP, ldap_opt_protocol_version, 3),
    ldap_simple_bind_s(LDAP,
                       'cn=read-only-admin,dc=example,dc=com',
                       'password'),
    ldap_search(LDAP,
        query(
            base('dc=example,dc=com'),
            scope(ldap_scope_subtree),
            filter('(objectClass=*)'),
            attrs([objectClass, description, cn]),
            attrsonly(false)
        ),
        MsgID),
    ldap_result(LDAP, MsgID, true, Result),
    ldap_parse_result(LDAP, Result, _, _, _, _, _, false),
    ldap_parse_search_result(LDAP, Result, List),
    print_term(List, []),
    ldap_msgfree(Result),
    ldap_unbind(LDAP).

Pre-set for free internet testing LDAP instance (or substitute your own). Test / sample output:

?- ['ldtest.pl'].
true.

?- ldtest:search.
[ _{ attributes:_{objectClass:[top,dcObject,organization]},
     dn:'dc=example,dc=com'
   },
  _{ attributes:_{ cn:[admin],
                   description:['LDAP administrator'],
                   objectClass:[ simpleSecurityObject,
                                 organizationalRole
                               ]
                 },
     dn:'cn=admin,dc=example,dc=com'
   },
  _{ attributes:_{ cn:['Isaac Newton'],
                   objectClass:[ inetOrgPerson,
                                 organizationalPerson,
                                 person,
                                 top
                               ]
                 },
     dn:'uid=newton,dc=example,dc=com'
   },
... ... ... ...

Thanks in advance to anyone willing to test it (let me know it works on other platforms, and I’ll send pull request to original repo (or update package info if dead).

Cheers, ares.

Are you aware that with Windows 10 you can install and run different Linux distros using Windows Subsystem for Linux. The Windows Subsystem for Linux lets developers run GNU/Linux environment – including most command-line tools, utilities, and applications – directly on Windows, unmodified, without the overhead of a virtual machine.

Vaguely aware, for now I haven’t had any reason to play with it (for me, “full linux” is better, and it’s a no-go at my workplace).

  • Hey, boss, can I install “Subsystem for Linux” on our production server(s) just so I can write some scripts in SWI Prolog ? Yes, I could write them in whatever. No, i don’t need psychiatric evaluation, but i guess that means no …

Same goes for user-facing apps, no-one is going to allow it. It would mean justifying it, changing “instalation template / specification”, waiting before it get tested so it could be deployed to ~ 5500 computers in some far-away future :-/

Now, a “native windows app” is another matter entirely, it requires “only” filling out a few documents, some amount of testing, some amount of bureaucracy - and only if it’s prominent (with few-enough users or low-enough visibility, it might fly without any process at all :slight_smile: )

Now, aren’t you all glad that some of us have to go through such hell, so that your libs are tested on windows ? ;-)))

1 Like