0
from ldap3 import Server, Connection, ALL
import pickle

server = Server('ipa.demo1.freeipa.org', get_info=ALL)
conn = Connection(server, 'uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org', 'Secret123', auto_bind=True)
entries = conn.extend.standard.paged_search('dc=demo1,dc=freeipa,dc=org', '(objectClass=person)', attributes=['cn', 'givenName', 'createtimestamp'], paged_size=5)

testlist = []

for entry in entries:
    testlist.append(entry)

output = open('data.pkl', 'wb')
pickle.dump(testlist, output)
output.close()

pkl_file = open('data.pkl', 'rb')
test2 = pickle.load(pkl_file)

pkl_file.close()

给...

C:\Python36\python.exe C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py
Traceback (most recent call last):
  File "C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py", line 20, in <module>
    test2 = pickle.load(pkl_file)
TypeError: __init__() missing 2 required positional arguments: 'offset' and 'name'

Process finished with exit code 1

这看起来与ldap3.core.timezone.py ...

createtimestamp属性看起来是datetime.datetime(2017, 6, 18, 11, 13, 38, tzinfo=OffsetTzInfo(offset=0, name='UTC'))

不幸的是,这是我不知道下一步该做什么的地方......这是在使用 datetime 对象本身进行酸洗之前应该解决的问题吗?

我无法使用常规的 Python 日期时间对象重新创建它。

4

0 回答 0