none
Backup and Restore LDAP RRS feed

  • Question

  • Hi, I'm new to c# and I'm developing an app for an openldap server.
    The server is a kind of address book that uses organizational units as contact groups. In the organizational units the entries are the contacts.
    I'm using System.DirectoryServices Namespace and it works almost everything. I can search for names or numbers and can edit, delete contacts or insert new ones. But I would need to backup and restore the organizational units and after days of searching I still have not found the way. Can someone help me? thank you.
    Monday, January 21, 2019 3:33 PM

All replies

  • Hi Manuel_p,

    Thank you for posting here.

    For your question, have you use database in your project?

    If yes, you could create a new table to store the original data to backup or restore. Or you could create a collection to store the original data.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 23, 2019 8:43 AM
    Moderator
  • Thanks for the reply Wendy.
    no database in my wpf app. it works like this: it reads all data from openldap on a linux server and places them in a datatable in the datagrid.

    However I managed to export the datatable to a comma-delimited csv. So I could have solved for backup.

    Instead for the recovery it is more complicated. First because I probably need to empty the organizational units to avoid that when I restore re-add some data already present. Unfortunately when I try to delete the data present with the following code :

    DirectoryEntry empty = new DirectoryEntry(
                        "LDAP://" + serverldap + "/OU=" + ouldap + "," + dcldap,
                        "cn=" + userldap + "," + dcldap, passuserldap,
                        AuthenticationTypes.ServerBind);

                empty.DeleteTree();

    I receive this error:

    System.DirectoryServices.DirectoryServicesCOMException: A protocol error occurred.

    Secondly because I do not know how to proceed to restore data from the csv. Would it be better to import data from the csv into an array or a datatable ? or can I read directly from the csv and maybe with a foreach line by line import it?

    If it can help in the csv the first line is an index (name, surname, email number etc ..).

    Thanks again for any help.

    Manuel.

    • Edited by Manuel_p Thursday, January 24, 2019 2:08 PM
    Thursday, January 24, 2019 2:06 PM
  • Hi Manuel_p,

    Thank you for feedback.

    We could save data to csv and read from csv, it could be used like a database to save and read data.

    If you want to convert datatable to CSV file, please try the code below.

    https://gist.github.com/gopigujjula/5458508

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Friday, February 1, 2019 7:38 AM
    Wednesday, January 30, 2019 5:51 AM
    Moderator