AcceptSecurityContext error when using ldapsearch against Active Directory - ldap

I am using ldapsearch to try to connect to an Active Directory LDAP server using this command (running on Ubuntu Linux):
ldapsearch -H ldap://SRV001 -D acme\SVC_LDAP_A -w mySecretPassword
However, I get:
ldap_bind: Invalid credentials (49)
additional info: 80090308: LdapErr: DSID-0C0903D9, comment: AcceptSecurityContext error, data 52e, v2580

The problem was that you need to quote the username, so change the command to:
ldapsearch -H ldap://SRV001 -D "acme\SVC_LDAP_A" -w mySecretPassword

Related

ldap_simple_bind: Invalid credentials

I'm trying a ldapsearch.
The user is "domain\user" and the connection and bind is successfull with ApacheDirectoryStudio (see image), however I don't understand how to use the -D parameter in ldapsearch (maybe the problem is the bachslash ?).
I've tried with:
ldapsearch -h IT.xxxx.COM -D "CN=domain\user,DC=it,DC=xxxx,DC=com" -w Password -b base 'objectClass=*'
but I get the error:
ldap_simple_bind: Invalid credentials --- 80090308: LdapErr:
DSID-0C090400, comment: AcceptSecurityContext error, data 52e
Thanks for help.
Giuseppe.k
Apache-Connection
For connecting to AD over LDAP, you either specify the LDAP DN (e.g. CN=user,DC=domain) or the AD UPN (e.g. user#domain).
In your case, remove the domain from the LDAP DN:
ldapsearch -h IT.xxxx.COM -D "CN=user,DC=it,DC=xxxx,DC=com" -w Password -b base 'objectClass=*'
The domain is already represented by DC=it,DC=xxxx,DC=com.

OpenLDAP SASL Authentication

I'm setting up this authentication through OpenLDAP:
OpenLDAP -> Pass-through (External authentication) -> SASL -> PAM -> RSA Agent
In order to access to an application via a RSA Token.
Starting from the bottom to the top:
This is my PAM configuration:
#%PAM-1.0
auth required pam_securid.so
account sufficient pam_ldap.so
account include password-auth
password sufficient pam_ldap.so
password include password-auth
This test works great:
[root#ldap ~]# testsaslauthd -u goingsolo -p 11111111
0: OK "Success."
OpenLdap is correctly configured to works with the SASL Authenticatino in PLAIN:
[root#ldap /]# ldapsearch -h localhost -b "" -LLL -s base supportedSASLMechanisms -x
dn:
supportedSASLMechanisms: PLAIN
And the userPassword of my goingsolo user is configured with {SASL}goingsolo And if I do a SASL bind it works:
[root#datap-keldap-1-n01 /]# ldapsearch -h localhost -b dc=ldap,dc=com -U "goingsolo" -w 11111111
SASL/PLAIN authentication started
0: OK "Success."
The problem is when I perform a simple bind with -D instead of -U, I receive invalid credentials:
[root#datap-keldap-1-n01 /]# ldapsearch -h localhost -b dc=ldap,dc=com -D "cn=goingsolo,ou=People,dc=ldap,dc=com" -w 11111111
ldap_bind: Invalid credentials (49)
Also when performing a sasl bind with the full dn, the authentication fails because from the /var/lag/messages:
Mar 27 19:01:00 ldap saslauthd[11777]: do_auth : auth failure: [user=cn=goingsolo,ou=People,dc=ldap,dc=com] [service=ldap] [realm=] [mech=pam] [reason=PAM auth error]
I guess this is because it does not a translate from the full dn to the simple user (goingsolo).
Any tips on what should I check?
The problem was how OpenLdap was build (I guess wrong compiling). I tryed to reinstall it and then it worked. Be sure the SASL machanism is set to plain.

How to bind a user and ensure they are in the correct group?

I think what I am trying to do is fairly simple, I want to setup ldap so that incoming binds check that the password is correct and the user is a member of a specific group.
Running the following query yields the following
ldapsearch -x -LLL -H ldap:/// -b uid=myname,ou=users,dc=example,dc=com dn memberof
Result
dn: uid=myname,ou=users,dc=example,dc=com
memberOf: cn=admin,ou=groups,dc=example,dc=com
I have tried the following query
ldapsearch -x -H "ldap://localhost" -D "(&(cn=My Name)(memberOf=cn=admin,ou=groups,dc=example,dc=com))" -W -b "dc=example,dc=com"
ldapsearch keeps throwing the following error
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
What am I doing wrong?
There are 2 things to fix in your search query :
the filter part should be placed after all options and before the list of attributes if any.
the -D option requires an argument, a bind dn to bind to the LDAP directory.
In other words : ldapsearch -x -H <ldapuri> -D <binddn> -W -b <basedn> <filter>
Assuming you can use this bind dn cn=manager,dc=example,dc=com, you should end up with a query looking like this :
ldapsearch -x -H "ldap://localhost" -D "cn=manager,dc=example,dc=com" -W -b "dc=example,dc=com" "(&(cn=My Name)(memberOf=cn=admin,ou=groups,dc=example,dc=com))"
https://linux.die.net/man/1/ldapsearch

ldapsearch with username and password

Here is my LDAP ORG Structure:
I created user with first, last name with password. But it is not working when am trying to connect using jdbc. Error says invalid credentials. Then I tried ldapsearch as follows:
I followed this process for users and group creation:
root#ip:/home# ldapwhoami
SASL/DIGEST-MD5 authentication started
Please enter your password:
ldap_sasl_interactive_bind_s: Invalid credentials (49)
additional info: SASL(-13): user not found: no secret in database
root#ip:/# ldapsearch -x -LLL -h ip -D username -w password -b"cn=admin,dc=ivhdev,dc=local" -s sub "(objectClass=*)" "givenName=username*"
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
Please suggest/correct me, if am passing the right info in DN syntax. I am unable to validate the user credentials with their name and password.
The -D option takes the DN for logging in to your LDAP server.
The -b option takes the search base in your LDAP tree where you want to search for the user's given name.
So, your ldapsearch command becomes:
ldapsearch -x -LLL -h ip -D 'cn=admin,dc=ivhdev,dc=local' -w password -b 'dc=users,dc=local' -s sub '(objectClass=*)' 'givenName=username*'
If you use the Apache Directory Studio (http://directory.apache.org/studio/) you can see the actual ldapsearch commands used by the application. Maybe this is useful for anyone.

How to find whether ldap server is up and running?

I have currently installed OID (Oracle Internet Directory) and created some roles and users in them. I intend to access them using LDAP commands.
$ldapbind -p <port_number> -h <ip> -D "cn=orcladmin"
bind sucessful
$ ldapsearch -h <port_number> -p <ip> "dc=<name>"
ldap_search: Inappropriate authentication
ldap_search: additional info: Server is Configured to Deny Anonymous Binds
Is there something I am missing ?
On your ldapsearch command, add the -D "cn=orcladmin" for who you are binding as, -w "Password" or -W to prompt at run time. Probably you want a -b "ou=Base,dc=DNtoSearch" and then your filter as you have it.
You need to bind each time.