Sponsored Content
Top Forums UNIX for Advanced & Expert Users ldap search to find dn for user Post 302440261 by cchart3 on Monday 26th of July 2010 03:40:06 PM
Old 07-26-2010
Data ldap search to find dn for user

How can I do a ldapsearch to find a DN for a user when I know the exact cn for that user out of active directory.

I have tried several different commands (hundreds) but need the -b with the full dn to perform the search using ldapsearch from AIX. I am trying to find the OU for a user and the sAMAccountName. Our user are in several different OU's.

example that works:
ldapsearch -h something.acorp.com -p 389 -D "cn=${USER},ou=RealOU,DC=something,DC=acorp,DC=com" -w "${PW}" -s sub -b "cn=${SEARCH_USER},ou=UsersRealOU,DC
=something,DC=acorp,DC=com" "cn=*"

example that does not work (one of many):
ldapsearch -h something.acorp.com -p 389 -D "cn=${USER},ou=RealOU,DC=something,DC=acorp,DC=com" -w "${PW}" -s sub "cn=${SEARCH_USER}"
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ldap search filter

Hi, I am trying to do an ldapsearch with a filter that checks the uid and the userpassword: $filter= "(&(uid=$user) (userpassword=$password)"; $objs = $ldap->search( base => $basedn, filter => "($filter)"); i based it on this example i found on CPAN: $mesg = $ldap->search( ... (2 Replies)
Discussion started by: tine
2 Replies

2. Programming

problem with ldap search using c

hi all i m writin a c program to search ldap db for values. i used the following code after search result return a value >0 if (result==1) { entry=ldap_first_entry(ld,msg); for(....;....;...) { // code to store the data values } } i m gettin an error at... (1 Reply)
Discussion started by: mridula
1 Replies

3. UNIX for Dummies Questions & Answers

LDAP search query help

I would like to do an ldap search which looks for entries which do not actually have a certain attribute. Not that the attribute is Null, but where the attribute does not exist. Is this possible using ldapsearch? (3 Replies)
Discussion started by: dopple
3 Replies

4. Linux

ldap user disabled

Hi All, If ldap user is disabled on linux. Do you think ldap processes will still run while ldap user had been disabled? Thanks for any comment you may add. (2 Replies)
Discussion started by: itik
2 Replies

5. Shell Programming and Scripting

LDAP user script

I am converting all users on all AIX systems to LDAP users. As such, I must delete the local user, and recreate the user via LDAP. When I delete the local user, all files and directories owned by the local user will revert to the UID. I need a script to find all files and directories belonging... (1 Reply)
Discussion started by: andybren
1 Replies

6. UNIX for Advanced & Expert Users

Determining if user is local-user in /etc/passwd or LDAP user

Besides doing some shell-script which loops through /etc/passwd, I was wondering if there was some command that would tell me, like an enhanced version of getent. The Operating system is Solaris 10 (recent-ish revision) using Sun DS for LDAP. (5 Replies)
Discussion started by: ckmehta
5 Replies

7. AIX

How to change normal user id to LDAP user id?

If I create a new user id test: mkuser id=400 test then I want it to LDAP user: chuser -R LDAP SYSTEM=LDAP registry=LDAP test It shows: 3004-687 User "test" does not exist. How to do? (4 Replies)
Discussion started by: rainbow_bean
4 Replies

8. UNIX for Dummies Questions & Answers

ldap search problem

I am posting in this section because in this regard I am a Dummy. I know very little about ldap. We have a couple of ldap registries running on an AIX box. I can connect into those registries using an openldap browser. But I am trying to run some queries against the registry on the server itself,... (1 Reply)
Discussion started by: fwellers
1 Replies

9. UNIX for Dummies Questions & Answers

ldap , search groups that user belong

i want run query to identify witch groups that user A belong, CN=name,CN=Users,DC=mydomain ?? (1 Reply)
Discussion started by: prpkrk
1 Replies

10. Shell Programming and Scripting

Ldap search query

Hi All, I have a existing Ldap query which take a HOME as variable and gives the result where i grep for a particular line. ldapsearch -h server_domain_name -p 389 -D "uid=user,ou=appadm,o=ent" -w PaB -b "ou=roles,o=ent" "cidx=$HOME" | grep -w "ent: xyz" Now i have 330K Homes in a... (1 Reply)
Discussion started by: posner
1 Replies
squid_ldap_group(8)					      System Manager's Manual					       squid_ldap_group(8)

NAME
squid_ldap_group - Squid LDAP external acl group helper SYNOPSIS
squid_ldap_group -b "base DN" -f "LDAP search filter" [options] [ldap_server_name[:port]|URI]... DESCRIPTION
This helper allows Squid to connect to a LDAP directory to authorize users via LDAP groups. LDAP options are specified as parameters on the command line, while the username(s) and group(s) to be checked against the LDAP directory are specified on subsequent lines of input to the helper, one username/group pair per line separated by a space. As expected by the external_acl construct of Squid, after specifying a username and group followed by a new line, this helper will produce either OK or ERR on the following line to show if the user is a member of the specified group. The program operates by searching with a search filter based on the users user name and requested group, and if a match is found it is determined that the user belongs to the group. -b basedn (REQUIRED) Specifies the base DN under which the groups are located. -B basedn Specifies the base DN under which the users are located (if different) -g Specifies that the first query argument sent to the helper by Squid is a extension to the basedn and will be temporarily added in front of the global basedn for this query. -f filter LDAP search filter used to search the LDAP directory for any matching group memberships. In the filter %u will be replaced by the user name (or DN if the -F or -u options are used) and %g by the requested group name. -F filter LDAP search filter used to search the LDAP directory for any matching users. In the filter %s will be replaced by the user name. If % is to be included literally in the filter then use %%. -u attr LDAP attribute used to construct the user DN from the user name and base dn without needing to search for the user. -s base|one|sub search scope. Defaults to 'sub'. base object only, one level below the base object or subtree below the base object -D binddn -w password The DN and password to bind as while performing searches. Required if the directory does not allow anonymous searches. As the password needs to be printed in plain text in your Squid configuration and will be sent on the command line to the helper it is strongly recommended to use a account with minimal associated privileges. This to limit the damage in case someone could get hold of a copy of your Squid configuration file or extracts the password used from a process listing. -D binddn -W secretfile The DN and the name of a file containing the password to bind as while performing searches. Less insecure version of the former parameter pair with two advantages: The password does not occur in the process listing, and the password is not being compromised if someone gets the squid configuration file without getting the secretfile. -P Use a persistent LDAP connection. Normally the LDAP connection is only open while verifying a users group membership to preserve resources at the LDAP server. This option causes the LDAP connection to be kept open, allowing it to be reused for further user val- idations. Recommended for larger installations. -R do not follow referrals -a never|always|search|find when to dereference aliases. Defaults to 'never' never dereference aliases (default), always dereference aliases, only while searching or only to find the base object -H ldapuri Specity the LDAP server to connect to by a LDAP URI (requires OpenLDAP libraries) -h ldapserver Specify the LDAP server to connect to -p ldapport Specify an alternate TCP port where the ldap server is listening if other than the default LDAP port 389. -v 2|3 LDAP protocol version. Defaults to 2 if not specified. -Z Use TLS encryption -Ecertpath Enable LDAP over SSL (requires Netscape LDAP API libraries) -cconnect_timeout Specify timeout used when connecting to LDAP servers (requires Netscape LDAP API libraries) -tsearch_timeout Specify time limit on LDAP search operations -S Strip NT domain name component from user names (/ or separated) -K Strip Kerberos Realm component from user names (@ separated) -d Debug mode where each step taken will get reported in detail. Useful for understanding what goes wrong if the results is not what is expected. SQUID CONFIGURATION
This helper is intended to be used as a external_acl_type helper from squid.conf. external_acl_type ldap_group %LOGIN /path/to/squid_ldap_group ... acl group1 external ldap_group Group1 acl group2 external ldap_group Group2 NOTES
When constructing search filters it is recommended to first test the filter using ldapsearch before you attempt to use squid_ldap_group. This to verify that the filter matches what you expect. AUTHOR
This manual page was written by Henrik Nordstrom <hno@marasystems.com> squid_ldap_group is written by Flavio Pescuma <flavio@marasystems.com> and Henrik Nordstrom <hno@squid-cache.org>, based on prior work in squid_ldap_auth by Glen Newton <glen.newton@nrc.ca> KNOWN LIMITATIONS
Max 16 occurrences of %s in the -u argument is supported. QUESTIONS
Any questions on usage can be sent to Squid Users <squid-users@squid-cache.org>, or to your favorite LDAP list/friend if the question is more related to LDAP than Squid. REPORTING BUGS
Report bugs or bug-fixes to Squid Bugs <squid-bugs@squid-cache.org> or ideas for new improvements to Squid Developers <squid-dev@squid- cache.org> SEE ALSO
squid_ldap_auth(8), ldapsearch(1), Your favorite LDAP documentation RFC2254 - The String Representation of LDAP Search Filters, Version 2.17 30 January 2005 squid_ldap_group(8)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy