-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_with_specific_attibute.sh
43 lines (33 loc) · 1.24 KB
/
search_with_specific_attibute.sh
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
#!/bin/bash
# LDAP Search for Entries with Specific Attribute Present
# Demonstrates searching for entries with a specific attribute present.
#This script includes comments explaining the purpose of the script and demonstrates how to perform an LDAP search to retrieve entries with a specific attribute present using the attribute=* syntax. The provided example showcases searching for entries within the specified search base, checking for the presence of the "mail" attribute.
# Connection Details
HOST="ldap.forumsys.com"
PORT=389
BIND_DN="cn=read-only-admin,dc=example,dc=com"
ADMIN_PASSWORD="password"
# Search for Entries with Specific Attribute Present
SEARCH_BASE="ou=Users,dc=example,dc=com"
ATTRIBUTE="mail"
# Running the ldapsearch command to check for attribute presence
ldapsearch -x -h $HOST -p $PORT -D "$BIND_DN" -w "$ADMIN_PASSWORD" -b "$SEARCH_BASE" "($ATTRIBUTE=*)"
<<OUTCOME
Sample Outcome:
# extended LDIF
#
# LDAPv3
# base <ou=Users,dc=example,dc=com> with scope subtree
# filter: (mail=*)
# requesting: ALL
#
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 2
dn: uid=john,ou=Users,dc=example,dc=com
mail: [email protected]
dn: uid=emma,ou=Users,dc=example,dc=com
mail: [email protected]
OUTCOME