1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

samba-tool domain: add LDB Result to json encoders

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2024-02-22 16:16:17 +13:00 committed by Andrew Bartlett
parent bbd9249a9c
commit e5efa21746

View File

@ -25,7 +25,7 @@ from datetime import datetime
from decimal import Decimal from decimal import Decimal
from enum import Enum from enum import Enum
from ldb import Dn from ldb import Dn, MessageElement, Result
from samba.dcerpc.security import descriptor from samba.dcerpc.security import descriptor
@ -40,8 +40,10 @@ class JSONEncoder(json.JSONEncoder):
""" """
def default(self, obj): def default(self, obj):
if isinstance(obj, (Decimal, Dn)): if isinstance(obj, (Decimal, Dn, MessageElement)):
return str(obj) return str(obj)
if isinstance(obj, Result):
return obj.msgs
elif isinstance(obj, Enum): elif isinstance(obj, Enum):
return str(obj.value) return str(obj.value)
elif isinstance(obj, datetime): elif isinstance(obj, datetime):