I've been trying to get logonHours
to display, while using the pyad
in Python 3.7. When I go to display logonHours, as an output it gives me
memory at 0x0000000003049708
etc.
Not sure how to display that data. All other attributes displays properly.
from pyad import *
q = pyad.adsearch.ADQuery()
q.execute_query(
attributes= ["distinguishedName", "givenName", "userWorkstations","homeDirectory", "homeDrive", "logonHours"],
where_clause = "objectClass = '*'",
base_dn = "OU=Graphic Design Students, DC=someplace, DC=com"
)
adoutput = []
for row in q.get_results():
adoutput.append(row["distinguishedName"])
adoutput.append(row["givenName"])
adoutput.append(row["userWorkstations"])
adoutput.append(row["homeDirectory"])
adoutput.append(row["homeDrive"])
adoutput.append(row["logonHours"])
adoutput = [x for x in adoutput if x != None]
print(adoutput)
my output looks like:
<memory at 0x0000000003049708>
<memory at 0x00000000030497C8>
<memory at 0x0000000003049888>
<memory at 0x0000000003049948>
<memory at 0x0000000003049A08>
<memory at 0x0000000003049AC8>
Use
row["logonHours"].tobytes()
to get the byte value -- you'll see the same fairly cryptic thing that ADSIEdit shows for the attribute value.
The trick then is turning it into something not cryptic. There's a good explanation of how the value is encoded at https://social.technet.microsoft.com/Forums/exchange/en-US/545552d4-8daf-4dd8-8291-6f088f35c2a4/how-is-the-logon-hours-attribute-set-in-active-directory-windows-server-2008-r2-?forum=winserverDS