problems accessing object [<COMObject GetEx>] using python pyad

微笑、不失礼 提交于 2019-12-07 18:26:13

问题


I'm having problems trying to access the active directory user attribute using pyad. Here is my code:

user = pyad.aduser.ADUser.from_cn("tuser")
print user.get_attribute(lastLogonTimestamp")

These are the printed attributes:

C:\Users\tuser\Desktop\docb0t>python docb0t.py
[<COMObject GetEx>]

I have no idea how to retrieve the value off that object. How can I do it?


回答1:


I ran into this same issue and after a little digging figured out the answer. You need to run the attribute through the pyadutils.convert_datetime function.

print pyadutils.convert_datetime(user.get_attribute('lastLogonTimeStamp', False))

Enjoy!

TriSkulL



来源:https://stackoverflow.com/questions/21520859/problems-accessing-object-comobject-getex-using-python-pyad

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