因此,我的第一次使用ldap3的經驗並未按計劃進行。我無法從http://ldap3.readthedocs.io/abstraction.htmlPython ldap3閱讀器調用失敗
s = Server('server')
c = Connection(s, user = 'username', password = 'password')
query = 'Department: Accounting' # explained in next paragraph
person_reader = Reader(c, person, 'o=test', query)
person_reader.search()
這看起來很簡單弄清楚爲什麼這是不工作...
代碼示例。但是,我的代碼,適用於服務器和連接調用,可以在Reader調用中發送大塊數據。下面的代碼片段:
query = 'department: Security Risk'
person_reader = Reader(c, person, 'OU=All Businesses', query)
和的fugly結果
AttributeError Traceback (most recent call last)
in()
1 query = 'department: Security Risk'
----> 2 person_reader = Reader(c, person, 'OU=All Businesses', query)
C:\Users########\AppData\Local\Continuum\Anaconda3\lib\site-packages\ldap3\abstract\reader.py in init(self, connection, object_def, query, base, components_in_and, sub_tree, get_operational_attributes, controls)
79 self.base = base
80 self._components_in_and = components_in_and
---> 81 self.attributes = sorted([attr.name for attr in self._definition])
82 self.get_operational_attributes = get_operational_attributes
83 self.controls = controls
C:\Users##########\AppData\Local\Continuum\Anaconda3\lib\site-packages\ldap3\abstract\reader.py in (.0)
79 self.base = base
80 self._components_in_and = components_in_and
---> 81 self.attributes = sorted([attr.name for attr in self._definition])
82 self.get_operational_attributes = get_operational_attributes
83 self.controls = controls
AttributeError: 'str' object has no attribute 'name'
每暢達列表:
ldap3 1.0.4 py35_0`
缺少什麼我在這裏?
你是否調用'person_reader.search()'?你的代碼示例說不。 –
僅供參考:我正在使用Anaconda Python版本3.5.2 – Harvey
另外,什麼是'人'?它似乎是未定義的。 –