Bird
Raised Fist0
Cybersecurityknowledge~10 mins

Directory services (Active Directory, LDAP) in Cybersecurity - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the protocol used by LDAP.

Cybersecurity
protocol = "[1]"
Drag options to blanks, or click blank then click option'
ALDAP
BHTTP
CFTP
DSMTP
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Confusing LDAP with HTTP or FTP protocols.
Using SMTP which is for email.
2fill in blank
medium

Complete the sentence to identify the Microsoft directory service.

Cybersecurity
The Microsoft directory service is called [1].
Drag options to blanks, or click blank then click option'
AActive Directory
BKerberos
CDNS
DOpenLDAP
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Confusing Active Directory with DNS or Kerberos.
Thinking OpenLDAP is Microsoft’s directory service.
3fill in blank
hard

Fix the error in the LDAP query filter to find users with the surname 'Smith'.

Cybersecurity
filter = "(sn=[1])"
Drag options to blanks, or click blank then click option'
Aname
Bsurname
Csn
DSmith
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using attribute names instead of the actual value.
Using 'surname' instead of 'sn' as attribute.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps usernames to their email addresses from a list of user objects.

Cybersecurity
user_emails = { [1]: user.email for user in users if user.[2] is not None }
Drag options to blanks, or click blank then click option'
Auser.username
Buser.name
Cemail
Dusername
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using incorrect attribute names for keys or conditions.
Confusing the key and value positions.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase usernames to their email addresses only if the email contains '@company.com'.

Cybersecurity
user_dict = { [1]: [2] for user in users if [3] }
Drag options to blanks, or click blank then click option'
Auser.username.upper()
Buser.email
C"@company.com" in user.email
Duser.name
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Not converting usernames to uppercase.
Incorrectly checking the email domain.
Using wrong attributes for keys or values.

Practice

(1/5)
1. What is the primary purpose of directory services like Active Directory or LDAP?
easy
A. To store and organize information about users and resources on a network
B. To provide antivirus protection for computers
C. To manage internet browsing history
D. To encrypt email messages automatically

Solution

  1. Step 1: Understand directory services function

    Directory services are designed to keep track of users, computers, and other resources in a network.
  2. Step 2: Identify the correct purpose

    Among the options, only storing and organizing network information matches the role of directory services.
  3. Final Answer:

    To store and organize information about users and resources on a network -> Option A
  4. Quick Check:

    Directory services = store network info [OK]
Hint: Directory services manage network users and resources [OK]
Common Mistakes:
  • Confusing directory services with security software
  • Thinking directory services handle internet browsing
  • Assuming directory services encrypt emails
2. Which of the following is the correct protocol used by Active Directory to query directory information?
easy
A. HTTP
B. SMTP
C. FTP
D. LDAP

Solution

  1. Step 1: Recall Active Directory protocols

    Active Directory uses LDAP (Lightweight Directory Access Protocol) to query and update directory data.
  2. Step 2: Match protocol to options

    Among the options, only LDAP is the directory query protocol; HTTP, FTP, and SMTP serve other purposes.
  3. Final Answer:

    LDAP -> Option D
  4. Quick Check:

    Active Directory uses LDAP [OK]
Hint: LDAP is the directory query protocol for Active Directory [OK]
Common Mistakes:
  • Choosing HTTP which is for web traffic
  • Confusing FTP with file transfer only
  • Selecting SMTP which is for email sending
3. Consider this LDAP query filter: (objectClass=user). What does this filter do when querying a directory?
medium
A. Returns all objects that are users
B. Returns all objects that are computers
C. Returns all objects with no class
D. Returns all objects that are groups

Solution

  1. Step 1: Understand LDAP filter syntax

    The filter (objectClass=user) selects directory entries where the objectClass attribute equals 'user'.
  2. Step 2: Identify what objectClass=user means

    This means the query returns all user objects, not computers or groups.
  3. Final Answer:

    Returns all objects that are users -> Option A
  4. Quick Check:

    LDAP filter (objectClass=user) = user objects [OK]
Hint: objectClass=user filter selects user entries [OK]
Common Mistakes:
  • Thinking it returns computers or groups
  • Misreading the filter syntax
  • Assuming it returns all objects regardless of type
4. You wrote this LDAP query filter to find all groups: (objectClass=group). But it returns no results. What is the most likely reason?
medium
A. The filter syntax is incorrect and should be (objectClass==group)
B. You need to use (objectCategory=group) instead for better results
C. The directory does not contain any group objects
D. LDAP does not support filtering by objectClass

Solution

  1. Step 1: Check LDAP filter syntax

    The syntax (objectClass=group) is correct, so syntax error is unlikely.
  2. Step 2: Understand objectClass vs objectCategory

    In Active Directory, objectCategory is often more reliable for filtering groups than objectClass.
  3. Step 3: Identify the best filter

    Using (objectCategory=group) usually returns group objects correctly.
  4. Final Answer:

    You need to use (objectCategory=group) instead for better results -> Option B
  5. Quick Check:

    Use objectCategory=group for groups [OK]
Hint: Use objectCategory=group to reliably find groups [OK]
Common Mistakes:
  • Assuming no groups exist in directory
  • Using double equals in LDAP filter
  • Believing LDAP can't filter by objectClass
5. You want to create an LDAP query to find all users who are members of a specific group named "SalesTeam". Which filter correctly combines these conditions?
hard
A. (&(objectClass=group)(memberOf=SalesTeam))
B. (|(objectClass=user)(memberOf=SalesTeam))
C. (&(objectClass=user)(memberOf=CN=SalesTeam,OU=Groups,DC=example,DC=com))
D. (objectClass=user)(memberOf=SalesTeam)

Solution

  1. Step 1: Understand LDAP filter operators

    The & operator means AND, | means OR. To find users who are members of a group, both conditions must be true.
  2. Step 2: Analyze each filter

    (&(objectClass=user)(memberOf=CN=SalesTeam,OU=Groups,DC=example,DC=com)) correctly uses AND to combine user objects with the memberOf attribute matching the full distinguished name of the group. (|(objectClass=user)(memberOf=SalesTeam)) uses OR, which is incorrect. (objectClass=user)(memberOf=SalesTeam) lacks an operator to combine conditions. (&(objectClass=group)(memberOf=SalesTeam)) looks for groups, not users.
  3. Final Answer:

    (&(objectClass=user)(memberOf=CN=SalesTeam,OU=Groups,DC=example,DC=com)) -> Option C
  4. Quick Check:

    Use AND (&) with objectClass=user and full memberOf DN [OK]
Hint: Use & to combine user and memberOf filters with full DN [OK]
Common Mistakes:
  • Using OR instead of AND to combine filters
  • Not using full distinguished name in memberOf
  • Filtering groups instead of users