-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate role with sAMAccountName from each user of a group: Bad search filter #228
Comments
Hi @datinho ! I can reproduce the error with # FAILS
filter: >
(&
(cn=*)
(objectClass=*)
)
# WORKS
filter: "(& (cn=*( (objectClass=*))" Can you confirm this ? That's a bug since |
Ok, the bug is that |
Hi @bersace,
but the binding was succesful
|
@datinho hmm, that's another issue. Does the |
I'm using an Active Directory |
🆙 can you test |
I've configured the yml e ldaprc:
Without filter, for example:
the users are read correctly. |
Again, can you test |
it missing flag -h, with it:
|
@datinho yes, ldap2pg suppose ldapwhoami will read ldaprc. |
@datinho can you have simple authentication ? $ ldapwhoami -h … -x -D OFFICE\\inetwork -W |
I guess yes
it also works if I use -D inetwork |
@datinho Can you do an anonymous $ ldapsearch -h … -s sub -b DC=office,DC=company,DC=com '(& (objectClass=User) (memberOf=CN=SQL-DBA,OU=SQL Groups,DC=office,DC=company,DC=com))' sAMAccountName
$ ldapsearch -h … -s sub -b DC=office,DC=company,DC=com '' sAMAccountName Adpat to your need. |
Hi, the anonymous search works. |
@datinho ok, nice. Let me know it some doc or better error message can help. |
Hi @bersace, ldapsearch -x -D inetwork -W -b DC=office,DC=company,DC=com -s sub '(& (objectClass=User) (memberOf=CN=SQL-DBA,OU=SQL Groups,DC=office,DC=company,DC=com))' sAMAccountName
Enter LDAP Password: and I get all samaccountname from the group but ldap2pg still returns error: [ldap2pg.ldap DEBUG] Doing: ldapsearch -x -D inetwork -W -b DC=office,DC=company,DC=com -s sub '(& (objectClass=User) (memberOf=CN=SQL-DBA,OU=SQL Groups,DC=office,DC=company,DC=com))' sAMAccountName
[ldap2pg.script CRITI] Failed to query LDAP: {'desc': 'Operations error', 'info': '000004DC: LdapErr: DSID-0C0907C2, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580'}. Note: if I use only the directive base with a single distinguished name I don't have error and get the samAccountName - ldap:
base: CN=My Name,OU=It Group,OU=Network,DC=office,DC=company,DC=com
role:
name_attribute: sAMAccountName
options: LOGIN SUPERUSER |
Hi @bersace, I've found the root problem, it's due to referral that is handled differently between LDAP and AD. Adding at line 206 of ldap.py: After that I've faced to another problem because the ldapsearch had returne dall users of group and mutiple search reference: so I've added a check at line 52 to avoid to add empty entries. I hope that could be useful. |
@datinho you're awesome ! I'll check this asap ! |
@datinho Do you feel confident to submit a pull request? :-) |
Let's close. Thanks @datinho ! |
Hi, with the fix setting referrals in the config to 'False', false, False of 'false' cannot deactivate referrals.. conn.set_option(ldap.OPT_REFERRALS, int(options.get('REFERRALS', False))) Can you please have a look ? Thanks |
Thanks for looking into it. I do not think it works. I can't tell why. |
@thda, can you show me a snippet of YAML ? |
Ref. #128
ldap2pg -V
ldap2pg 4.11
psycopg2 2.7.5 (dt dec pq3 ext lo64)
python-ldap 3.1.0
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
OS: Centos 7
I've configured the yml file: ldap2pg.yml
running the command: ldap2pg -c ./ldap2pg.yml -n -vvv
I receive the error, but if I run the command line: ldapsearch -h pdc.office.company.com -D "CN=inetwork,OU=Network/Nweb Service Account,DC=office,DC=company,DC=com" -W -Y DIGEST-MD5 -U inetwork -W -b DC=office,DC=company,DC=com -s sub '(&(objectClass=User)(memberOf=CN=SQL-DBA,OU=SQL Groups,DC=office,DC=company,DC=com))' sAMAccountName
It returns the sAMAccountName of related group and I cannot use the CN because is space separated.
Thanks in advance.
The text was updated successfully, but these errors were encountered: