LDIF Parser (C#)

喜夏-厌秋 提交于 2019-12-18 06:57:01

问题


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) causes an entry in the error logs.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/2270334/ldif-parser-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!