khazadum Mesaj tarihi: Ağustos 22, 2021 Paylaş Mesaj tarihi: Ağustos 22, 2021 Selamlar, Bir proje 'de Python ile DC'deki ou listesini alıp arayüzde göstermem gerekti. (Tree view şeklinde) Python 'da ldap3 kütüphanesi kullanarak OU listesini alabiliyorum. Python şu şekilde; from ldap3 import Server, Connection, LEVEL, SUBTREE from ldap3.core.exceptions import LDAPCursorError server = Server('x.x.x.x', port=389, use_ssl=False, get_info='ALL') connection = Connection(server, 'x\\administrator', '123', auto_bind=True) elements = connection.extend.standard.paged_search( search_base="DC=host,DC=com", search_filter='(objectCategory=organizationalUnit)', search_scope=SUBTREE, paged_size=100) for e in elements: if 'raw_dn' in e: print(e) Bana şu şekilde bir çıktı veriyor; { "raw_dn":"OU=IT,DC=x,DC=com", "dn":"OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=HR,DC=x,DC=com", "dn":"OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Accounting,DC=x,DC=com", "dn":"OU=Accounting,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Purchase,DC=x,DC=com", "dn":"OU=Purchase,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Planning,DC=x,DC=com", "dn":"OU=Planning,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Software,OU=IT,DC=x,DC=com", "dn":"OU=Software,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Hardware,OU=IT,DC=x,DC=com", "dn":"OU=Hardware,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Network,OU=IT,DC=x,DC=com", "dn":"OU=Network,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Safety_and_Health,OU=HR,DC=x,DC=com", "dn":"OU=Safety_and_Health,OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Administrative_Affairs,OU=HR,DC=x,DC=com", "dn":"OU=Administrative_Affairs,OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Tax_Accounting,OU=Accounting,DC=x,DC=com", "dn":"OU=Tax_Accounting,OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Cost_Accounting,OU=Accounting,DC=x,DC=com", "dn":"OU=Cost_Accounting,OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Database,OU=Software,OU=IT,DC=x,DC=com", "dn":"OU=Database,OU=Software,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Backend,OU=Software,OU=IT,DC=x,DC=com", "dn":"OU=Backend,OU=Software,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Frontend,OU=Software,OU=IT,DC=x,DC=com", "dn":"OU=Frontend,OU=Software,OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" } Buradaki olay iç içe olan OU gruplarını parent-child şeklinde göstermemesi. Çıktı da göründüğü üzere her bir child OU için yeni bir obje yapması. Aslında şöyle olmasını istiyorum; - IT - Software - Database - Backend - Frontend - Hardware - Network - HR - Safety_and_Health - Administrative_Affairs - Accounting - Tax_Accounting - Cost_Accounting - Purchase - Planning { "raw_dn":"OU=IT,DC=x,DC=com", "dn":"OU=IT,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry", "child": [ { "raw_dn":"OU=Software,DC=x,DC=com", "dn":"OU=Software,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry", "child": [ { "raw_dn":"OU=Database,DC=x,DC=com", "dn":"OU=Database,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Backend,DC=x,DC=com", "dn":"OU=Backend,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Frontend,DC=x,DC=com", "dn":"OU=Frontend,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" } ] }, { "raw_dn":"OU=Hardware,DC=x,DC=com", "dn":"OU=Hardware,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Network,DC=x,DC=com", "dn":"OU=Network,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" } ] }, { "raw_dn":"OU=HR,DC=x,DC=com", "dn":"OU=HR,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry", "child": [ { "raw_dn":"OU=Safety_and_Health,DC=x,DC=com", "dn":"OU=Safety_and_Health,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Administrative_Affairs,DC=x,DC=com", "dn":"OU=Administrative_Affairs,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry } ] }, { "raw_dn":"OU=Accounting,DC=x,DC=com", "dn":"OU=Accounting,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry", "child": [ { "raw_dn":"OU=Tax_Accounting,DC=x,DC=com", "dn":"OU=Tax_Accounting,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Cost_Accounting,DC=x,DC=com", "dn":"OU=Cost_Accounting,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" } ] }, { "raw_dn":"OU=Purchase,DC=x,DC=com", "dn":"OU=Purchase,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" }, { "raw_dn":"OU=Planning,DC=x,DC=com", "dn":"OU=Planning,DC=x,DC=com", "raw_attributes":{}, "attributes":{}, "type":"searchResEntry" } Bu konuda yardımcı olabilecek birileri var mı? Kafayı yemek üzereyim bir kaç gündür Link to comment Sosyal ağlarda paylaş Daha fazla paylaşım seçeneği…
cabiria Mesaj tarihi: Ağustos 22, 2021 Paylaş Mesaj tarihi: Ağustos 22, 2021 for e in elements: if 'raw_dn' in e: print(e) bu kısımda parent-child olaylarını tekrar ayarlayıp, dict'i öyle print etsen olmaz mı Link to comment Sosyal ağlarda paylaş Daha fazla paylaşım seçeneği…
Öne çıkan mesajlar