Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LDIF Parser in Java (LDIF->JSON)

Tags:

java

json

ldap

ldif

Do you know any java library (or sth other maybe script?) that allows you to 'convert' LDIF to JSON?

JSON data is easier for me to process, So an easy way to make such conversion would be really useful. Also I don't want to reinvent the wheel:)

Cheers

like image 315
damian Avatar asked Jan 28 '26 14:01

damian


1 Answers

This seems to be what you are after.

You should be able to do something like:

StringWriter writer = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(writer);
FileReader reader = new FileReader("entry.ldif");
LdifReader ldifReader = new LdifReader(reader);
SearchResponse result = ldifReader.read();
jsonWriter.write(result);
System.out.println(writer.toString());

Here is a PHP script I found on github as well that does from ldif to JSON or XML. I don't know the quality of it.

like image 101
Jordan Stewart Avatar answered Jan 30 '26 03:01

Jordan Stewart