I am trying to retrieve all AD-GROUP Names using python from LDAP. using "ldap3" python library.
I failed to find a way to get through using python. Can you please let me know if you guys have any idea to get it.
I am can retrieve ALL available AD-GROUPS using a "power shell" with a simple command. and saving to file.
Powershell code is:
$op = @()
#This below line doing everything I need.
$ADGROUPS = GET-ADGroup -Filter *
#Then filtering what I need.
foreach($grp in $ADGROUPS)
{
$g = "" | Select "name", "dn", "member"
$g.name = $grp.name
$g.dn = $grp.distinguishedName
$g.member = $grp.member
$op += $g
}
# Saving to csv file.
$op | Export-Csv "groups.csv"
I need the same thing in python.
To retrieve in python for other things, I am using this flow. But to fetch groups I am not getting it.
from ldap3 import Server, Connection, ALL
ldap_conn = Connection(server, ... bla bla)
ldap_conn.search(
search_base=my_dn,
search_filter= '(????)', # required
search_scope=ldap3.SUBTREE,
attributes='*'
)
Can someone help me in it or a similar one to find all AD-GROUP names?