Advertisement

11.28.2007 at 01:21AM PST, ID: 22987037
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

LDAP Search syntax for finding entries with multiple equal attributes
Tags: ldap, search, syntax
Hi Experts,

I am moderately acquainted with the general syntax of LDAP search queries. However I don't seem to get my hands around how to do an LDAP search for entries that have two or more attributes of a certain name.

Take as an example the mini-LDIF in the code-snippet section. The user John Doe has two rights, namely "user" and "employer". It isn't hard to find any person with user and employer rights:

    (&(right=user)(right=employer))

however, I would like to find all users with two rights or more. One right would be easy:

    (right=*)

but that is not enough. Is there a way to query an LDAP directory for all persons that have two or more rights (or any other attribute for that matter)?

Any help is greatly appreciated.

Cheers,
-- Abel --
1:
2:
3:
4:
5:
objectClass: person
cn: John Doe
sn: Doe
right: user
right: employer
Start your free trial to view this solution
Question Stats
Zone: Database
Question Asked By: abel
Solution Provided By: MSE-dwells
Participating Experts: 1
Solution Grade: A
Views: 85
Translate:
Loading Advertisement...
11.30.2007 at 06:01AM PST, ID: 20381917

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 08:29AM PST, ID: 20383190

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 08:47AM PST, ID: 20383360

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:00AM PST, ID: 20383445

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:01AM PST, ID: 20383452

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:03AM PST, ID: 20383465

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:04AM PST, ID: 20383475

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:14AM PST, ID: 20383528

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:17AM PST, ID: 20383554

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:41AM PST, ID: 20383738

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:49AM PST, ID: 20383794

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.30.2007 at 09:51AM PST, ID: 20383812

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.04.2007 at 02:27AM PST, ID: 20401929

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.04.2007 at 06:25AM PST, ID: 20402928

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.04.2007 at 06:47AM PST, ID: 20403124

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.04.2007 at 07:19AM PST, ID: 20403422

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.04.2007 at 07:20AM PST, ID: 20403439

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 06:28AM PST, ID: 20411397

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 06:31AM PST, ID: 20411420

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 06:35AM PST, ID: 20411463

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 08:55AM PST, ID: 20412920

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 08:58AM PST, ID: 20412960

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 09:00AM PST, ID: 20412987

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.05.2007 at 10:28AM PST, ID: 20413698

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.06.2007 at 01:47AM PST, ID: 20418353

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
11.30.2007 at 06:01AM PST, ID: 20381917

Rank: Master

Not natively since there's no operand or matching rule combinations that returns a count or one that returns TRUE based upon the number of values (only the value themselves.)

I'd suggest you use a simple script.  Note that the example I've provided uses a very popular and entirely free LDAP query tool available from http://joeware.net.  The script could look like this (the example provided functions per your requirements) -
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
@echo off
 
setlocal ENABLEDELAYEDEXPANSION
 
set attributeNAME=right
set attributeLENGTH=5
set hitTRIGGER=2
 
for /f "tokens=*" %%D in ('adfind -domain -f "%attributeNAME%=*" %attributeNAME% 2^>nul') do (
	set resultSTRING=%%D
	if /i "!resultSTRING:~0,3!"=="dn:" (
		if "!DNshown!"=="1" echo [!hitCOUNT!]
		set hitCOUNT=0
		set DNshown=0
		set objectDN=!resultSTRING:~3!
	)
	if /i "!resultSTRING:~1,%attributeLENGTH%!"=="%attributeNAME%" (
		set /a hitCOUNT+=1
		if !hitCOUNT! GEQ %hitTRIGGER% (
			if not "!dnSHOWN!"=="1" (
				set /p=!objectDN! <nul
				set DNshown=1
			)
		)
	)		
)
Open in New Window
 
11.30.2007 at 08:29AM PST, ID: 20383190
That looks rather cool! Thanks (I was worrying that my question was unsolvable). This looks like a rather strong use of the MS DOS Batch Extensions, very nice.

I downloaded and tried the adfind tool, but couldn't get it to connect to my server. It either says "Server down" (81) or "Authentication method not supported" (7), the latter only when I do not provide a login+pwd on the commandline.

Maybe it isn't suitable for Sun Directory Server 5.2? Do you know of any settings I am missing? Here's the commandline I tried:

adfind -h sso.local-ldap.com:60945 -c -u uid=user4,dc=local,dc=com -p test -b dc=local-ldap,dc=com -f "uid=user4"

(as you can see, I login as a certain user and try to query that same user, but it doesn't work yet). Any ideas?

Cheers & Thanks,
-- Abel --
 
11.30.2007 at 08:47AM PST, ID: 20383360

Rank: Master

What does this return -

adfind -h sso.local-ldap.com:60945 -c -simple -u uid=user4,dc=local,dc=com -up test -b dc=local-ldap,dc=com -f "uid=user4"

... try it without the -simple as well.

PS - I believe you meant -up for the password value -- did you also want to return just the object count (-c) that met your filter?

PPS - I confess, I've become so blinkered by Active Directory, I forget to even consider the potential for other DSs ... ughhh, sorry 'bout that.
 
11.30.2007 at 09:00AM PST, ID: 20383445
Getting closer....

After an "No Such Object" (32) error (which usually means the userid is or dn is wrong), I now have an "Unavailable Critical Extension" error. In full, it looks as this (see snippet)

any further ideas? Using Apache Directory Studio, I can connect fine (but that doesn't have handy commandline tools).
1:
2:
3:
4:
5:
6:
7:
8:
AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007
 
Enter Password: ......
Using server: :60945
 
ldap_get_next_page_s: [] Error 0xc (12) - Unavailable Critical Extension
 
0 Objects returned
Open in New Window
 
11.30.2007 at 09:01AM PST, ID: 20383452
PS: yes, it was my misinterpretation of the commandline explanations: using "-p" for "-up"....
 
11.30.2007 at 09:03AM PST, ID: 20383465
PPS: yes, the -c was on purpose, my first query looked like "uid=*" and I did not want the clutter, only the count.
 
11.30.2007 at 09:04AM PST, ID: 20383475

Rank: Master

Hmmm ... that seems to indicate your DS can't handle paging, I find that hard to believe though.  Is that correct?  Try tacking a -d on for further debugging-related output.

In addition, if we circumvent this issue, add this switch on there ........ -dloid

... it may also be trying to make some smart decisions by enumerating the schema which will fail since ADfind is NOT a generic LDAP query tool like LDIFDE, it's written specifically for AD or ADAM ... so we'll see.
 
11.30.2007 at 09:14AM PST, ID: 20383528
Hmm, maybe you can make something of this, but it looks like we're getting at the end of our options here. "-dloid" gave just the same error. "-d" is below:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007
 
DEBUG: Opening TCP connection
DEBUG: In OpenLDAP... Params:
DEBUG:    Server:    sso.local-ldap.com
DEBUG:    SSL: 0
DEBUG:    Port:        60945
DEBUG:    Ref:       1
DEBUG:    V3:        1
DEBUG:    Anonymous: 0
DEBUG:    userdn: uid=test,dc=local-ldap,dc=com
DEBUG:    password: test
DEBUG:    Simple: 1
DEBUG:    LDAP_OPT_ENCRYPT: 0
DEBUG:    Delegation: 0
DEBUG:    Extended Error Info: 0
LDAP_OPTION: Version 3
LDAP_BIND: [sso.local-ldap.com] Successful
DEBUG: Gathering RootDSE
DEBUG: Entering CRootDSE...
DEBUG: Leaving CRootDSE.
DEBUG: RootDSE Completed
Using server: :60945
 
DEBUG: Initializing Search Paging...
DEBUG: Search Initialized...
DEBUG: Have valid Search Handle...
DEBUG: Retrieving Page...
DEBUG: Temp Page Size: 1000
DEBUG: Object Count: 0
ldap_get_next_page_s: [] Error 0xc (12) - Unavailable Critical Extension
 
 
0 Objects returned
Open in New Window
 
11.30.2007 at 09:17AM PST, ID: 20383554

Rank: Master

Nod, that looks like your DS doesn't support paging.  From AD or ADAM, I get this -

C:\>adfind -h light -rootdse | find /i "pag"

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

>supportedControl: 1.2.840.113556.1.4.319 [LDAP_PAGED_RESULT_OID_STRING]

... the LDAP control, though a Microsoft control, is the industry standard since they introduced paging.
 
11.30.2007 at 09:41AM PST, ID: 20383738
aha.. I don't know, you maybe right, of course. But perhaps it is the story explained here? http://forum.java.sun.com/thread.jspa?threadID=5201270

Unfortunately, I have to go (it is 18.40 and it's Friday, time for weekend ;). Do you think this is resolvable? Or is another tool useful with your solution?
 
11.30.2007 at 09:49AM PST, ID: 20383794

Rank: Master

Nod, the script can be adapted readily enough.  It's just a matter of finding the tool to dump the data in the first place.  Perhaps if you formulate the LDIFDE syntax and throw it out an LDF file, I can adapt that script to fit.  Enjoy your weekend!
 
11.30.2007 at 09:51AM PST, ID: 20383812

Rank: Master

PS  - I'd also suggest dumping the rootDSE and seeing if it supports the control I mentioned ealier ... the unavailable crit. extension isn't necessarily indicative of this particular issue.
 
12.04.2007 at 02:27AM PST, ID: 20401929
I tried to use ldapsearch, which I found in the shared/bin directory of the Sun DS installation folder. It seems to work just fine and outputs as LDIF, I believe. Can I use that with your scriptlet?
1:
2:
3:
4:
5:
6:
dn: cn=obsfUser,ou=manager,ou=myCompany,ou=myEnterprise,dc=local-ldap,dc=com
objectClass: top
objectClass: person
right: view-roles
right: edit-roled
right: manage-employers
Open in New Window
 
12.04.2007 at 06:25AM PST, ID: 20402928

Rank: Master

Hmmm ... I'm not in a convenient position to test it right now but, at first glance, it looks like you could substitute the ADfind syntax in the script with the ldapsearch equiv.  Post back the LDAPsearch syntax and I'll see how we can incorporate it.
 
12.04.2007 at 06:47AM PST, ID: 20403124
This is the line I use to call it, not really rocket science ;)

ldapsearch -b dc=local-ldap,dc=com -T -p 60945 -D uid=user4,dc=local-ldap,dc=com -w user4 "(rights=*)"

Where:
-b is Base DN
-T is non-wrapped output (every line is on one line)
-p is port
-h is host (default localhost)
-D is bind dn
-w is password
last part is the query string in RFC-2254 syntax.

Full documentation is here in case you need any: http://docs.sun.com/source/816-6400-10/lsearch.html#wp19539
 
12.04.2007 at 07:19AM PST, ID: 20403422

Rank: Master

OK, is your attribute named 'right' or 'rights'?

Let's try this (I haven't tested it BTW) -
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
@echo off
 
setlocal ENABLEDELAYEDEXPANSION
 
set attributeNAME=rights
set attributeLENGTH=6
set hitTRIGGER=2
 
for /f "tokens=*" %%D in (ldapsearch -b dc=local-ldap,dc=com -T -p 60945 -D uid=user4,dc=local-ldap,dc=com -w user4 "(%attributeNAME%=*)" 2^>nul') do (
	set resultSTRING=%%D
	if /i "!resultSTRING:~0,3!"=="dn:" (
		if "!DNshown!"=="1" echo [!hitCOUNT!]
		set hitCOUNT=0
		set DNshown=0
		set objectDN=!resultSTRING:~3!
	)
	if /i "!resultSTRING:~1,%attributeLENGTH%!"=="%attributeNAME%" (
		set /a hitCOUNT+=1
		if !hitCOUNT! GEQ %hitTRIGGER% (
			if not "!dnSHOWN!"=="1" (
				set /p=!objectDN! <nul
				set DNshown=1
			)
		)
	)		
)
Open in New Window
 
12.04.2007 at 07:20AM PST, ID: 20403439

Rank: Master

Dang, the attribute is 'right' not 'rights' I think.  Change lines 5 and 6 in the script accordingly to account for that.
 
12.05.2007 at 06:28AM PST, ID: 20411397
> OK, is your attribute named 'right' or 'rights'?

actually, it is in Dutch: "rechten". I translated (and obfuscated) the output and apparently I wasn't all too consistent. But I should be capable enough to adjust your script accordingly ;)

I tried your script and needed to make a few adjustments: quotes around the -b and -D parameters (otherwise DOS interprets the equal sign and the comma as spaces) and a starting single quote for the command.

Result: naught. I also tried with "objectClass" as attribute, because almost all entries have two or more objectclass attributes. I tested the output of the error (you direct it to NUL) but that didn't reveal anything (no errors). Any ideas where I should look?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
@echo off
 
setlocal ENABLEDELAYEDEXPANSION
 
set attributeNAME=objectClass
set attributeLENGTH=11
set hitTRIGGER=2
 
for /f "tokens=*" %%D in ('ldapsearch -b "dc=local-ldap,dc=com" -T -p 60945 -D "uid=user4,dc=local-ldap,dc=com" -w user4 "(%attributeNAME%=*)" 2^>nul') do (
    set resultSTRING=%%D
    if /i "!resultSTRING:~0,3!"=="dn:" (
        if "!DNshown!"=="1" echo [!hitCOUNT!]
        set hitCOUNT=0
        set DNshown=0
        set objectDN=!resultSTRING:~3!
    )
    if /i "!resultSTRING:~1,%attributeLENGTH%!"=="%attributeNAME%" (
        set /a hitCOUNT+=1
        if !hitCOUNT! GEQ %hitTRIGGER% (
            if not "!dnSHOWN!"=="1" (
                set /p=!objectDN! <nul
                set DNshown=1
            )
        )
    )         
)
Open in New Window
 
12.05.2007 at 06:31AM PST, ID: 20411420
PS: in case you ask: yes, the query works, if run separately it returns a lot (I tested with removing @echo off which gave me the expanded command string). It also runs for a very long time when set to objectClass, which is as expected, the server contains about 50.000 entries.
 
12.05.2007 at 06:35AM PST, ID: 20411463

Rank: Master

Remove the 'echo off' and alter the filter such that the return-set is minimized ... paste the entire content back here ...
 
12.05.2007 at 08:55AM PST, ID: 20412920
I tried it, but made a little mistake (I left the "=*" in place) and after an hour it hadn't yet finished.... (though any normal query using a dump runs in about 1 mins)

Changing it to a 1-resultset by using a uid, it gives the following output (pardon the length, but you asked for the whole bit).
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
C:\>for /F "tokens=*" %D in ('ldapsearch -b "dc=local-ldap,dc=com" -T -p 60945 -D "uid=user4,dc=local-ldap,dc=com" -w user4 "(uid=user4)" 2>nul') do (
set resultSTRING=%D
 if /I "!resultSTRING:~0,3!" == "dn:" (
if "!DNshown!" == "1" echo [!hitCOUNT!]
 set hitCOUNT=0
 set DNshown=0
 set objectDN=!resultSTRING:~3!
)
 if /I "!result