LDIF Parser (C#)
I am looking for an LDIF parser for C#. I am trying to parse an LDIF file so that I can check objects don't exist before adding them. Adding them when the already exist using ntdsSchemaAdd) caus开发者_JAVA百科es an entry in the error logs.
A quick websearch revealed: http://wiki.github.com/skradel/Zetetic.Ldap/. They have provided a .net API.
From the page:
Zetetic.Ldap is a .NET library for .NET 2 and above, which makes it easier to work with directory servers (like Active Directory, ADAM, Red Hat Directory Server, and others). Some of the key features of Zetetic.Ldap are:
1.LDIF file parsing and generation – Read and write the file format used for moving data around between directory systems
2.LDAP Entry-oriented API with change tracking – Create and modify directory objects in a more natural way
3.LDAP Schema interrogation – Quick programmatic access to the kinds of objects and fields your directory server understands. Learn if an attribute is a string, a number, a date, etc., without lots of manual research and re-parsing
4.LDIF Pivoter – Turn an LDIF file into a (comma or tab-delimited) flat file for analysis or loading into systems that don’t speak LDIF We built the Zetetic.Ldap library to make directory projects and programming faster and easier, and release it here in the hopes that others will find it useful too. As far as we know, this is the only .NET library that really understands the LDIF specification.
Download link: http://github.com/downloads/skradel/Zetetic.Ldap/Zetetic.Ldap_20090831.zip
I would parse it myself.
If you look at the LDIF RFC for the EBNF, you'll see that it's not a very complex grammar.
I've parsed a large amount of LDIF before using Regexes reliably. Though your mileage may vary.
精彩评论