[Python] How to add record to local samba file *.ldb?

Discussão em 'Python' iniciado por Stack, Fevereiro 10, 2025.

  1. Stack

    Stack Membro Participativo

    I use python3 and package python3-ldb. My script:

    import ldb

    from ldb import MessageElement, Message

    dbl = ldb.Ldb("base.ldb")


    for k in dbl.search("CN=admin,CN=Users,DC=nulex,DC=test"):

    for i in k.items():
    print(i)


    k.add(ldb.MessageElement('ssdfsdf', ldb.FLAG_MOD_ADD, "MYMYSSS"))



    I see all record, but I can't add new record or modify record.

    output:

    Traceback (most recent call last):
    File "/home/djvu/projects/dd.py", line 122, in <module>
    k.add(ldb.MessageElement('ssdfsdf', ldb.FLAG_MOD_ADD, "MYMYSSS"))
    _ldb.LdbError: (1, 'Operations error')



    How to do it? Thx for help.

    Continue reading...

Compartilhe esta Página