2012-11-16 48 views

回答

0

你應該真的需要閱讀的python-LDAP的文檔http://www.python-ldap.org/docs.shtml

You have a connection in your variable l, then you can do this. 

l.con_search_s('dc=your,dc=base,dc=dit', ldap.SCOPE_SUBTREE, 'uid=*', ['uid', 'uidnumber']) 

The above code, goint to search in to all the uid's entrys, for if entry, is going to get the uid and the uidnumbre attributes. 
4

你可以做相當多的也使用win32com.client(我已經很難找到的文檔)。例如,我需要知道他的ADS_NAME_TYPE_NT4格式化名稱(doman\jonjoe)來解析用戶的電子郵件。

所有你需要將其轉換爲ADS_NAME_TYPE_1779格式(CN=Jeff Smith,CN=users,DC=Fabrikam,DC=com)首先:

name_resolver = win32com.client.Dispatch(dispatch='NameTranslate') 
name_resolver.Set(3, 'domain\\jonjoe') 
ldap_query = 'LDAP://{}'.format(name_resolver.Get(1)) 

一旦你有,你可以簡單地調用GetObject()

ldap = win32com.client.GetObject(ldap_query) 
print(ldap.Get('mail')) 

測試與Python 3.2.5

+0

該庫還可以解析源自不同的外部安全主體的域森林通過單向信任連接? –

+0

@AndrzejBobak它基本上只是包裝WinAPI,所以如果你可以在WinAPI中編寫它,你可以使用'win32 *'python庫重寫它。 – Vyktor

相關問題