Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape special characters in LDAP filter #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Snapshots/LDAP/lib/SessionTutorial/Controller/Tutorial.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions Snapshots/Logging/lib/SessionTutorial/Controller/Tutorial.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions Snapshots/Redirect/lib/SessionTutorial/Controller/Tutorial.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions docs/Advent_calendar/Authenticating_LDAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => join('=', $user_attr, $username),
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions docs/LDAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Replace the body of `check_credentials()` with the following
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => join('=', $user_attr, $username),
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions old_files/ldap/lib/LDAP/Controller/Login.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down
2 changes: 2 additions & 0 deletions session_tutorial/lib/SessionTutorial/Controller/Tutorial.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ sub check_credentials {
my $ldap = Net::LDAP->new( $LDAP_server )
or warn("Couldn't connect to LDAP server $LDAP_server: $@"), return;

# Escape special chacarters in the username
$username =~ s/([*()\\\x{0}])/sprintf '\\%02x', ord($1)/ge;
my $search = $ldap->search( base => $base_DN,
filter => "$user_attr=$username",
attrs => [$user_id],
Expand Down