Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Ng
OpenLDAP
Commits
d6444a10
Commit
d6444a10
authored
17 years ago
by
Gavin Henry
Browse files
Options
Downloads
Patches
Plain Diff
Running 'perlcritic -1 SampleLDAP.pm' and tidying up.
parent
53fcfd93
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
servers/slapd/back-perl/SampleLDAP.pm
+97
-101
97 additions, 101 deletions
servers/slapd/back-perl/SampleLDAP.pm
with
97 additions
and
101 deletions
servers/slapd/back-perl/SampleLDAP.pm
+
97
−
101
View file @
d6444a10
package
SampleLDAP
;
use
strict
;
use
warnings
;
use
POSIX
;
# This is a sample Perl module for the OpenLDAP server slapd.
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
...
...
@@ -23,150 +28,141 @@
#
# See the slapd-perl(5) manual page for details.
package
SampleLDAP
;
our
$VERSION
=
'
1.00
'
;
use
POSIX
;
sub
new
{
my
$class
=
shift
;
sub
new
{
my
$class
=
shift
;
my
$this
=
{};
bless
$this
,
$class
;
print
STDERR
"
Here in new
\n
";
print
STDERR
"
Posix Var
"
.
BUFSIZ
.
"
and
"
.
FILENAME_MAX
.
"
\n
";
return
$this
;
my
$this
=
{};
bless
$this
,
$class
;
print
<
STDERR
>
,
"
Here in new
\n
";
print
<
STDERR
>
,
'
Posix Var
'
.
BUFSIZ
.
'
and
'
.
FILENAME_MAX
.
"
\n
";
return
$this
;
}
sub
init
{
return
0
;
sub
init
{
return
0
;
}
sub
search
{
my
$this
=
shift
;
my
(
$base
,
$scope
,
$deref
,
$sizeLim
,
$timeLim
,
$filterStr
,
$attrOnly
,
@attrs
)
=
@_
;
print
STDERR
"
====
$filterStr
====
\n
";
$filterStr
=~
s/\(|\)//g
;
$filterStr
=~
s/=/: /
;
sub
search
{
my
$this
=
shift
;
my
(
$base
,
$scope
,
$deref
,
$sizeLim
,
$timeLim
,
$filterStr
,
$attrOnly
,
@attrs
)
=
@_
;
print
<
STDERR
>
,
"
====
$filterStr
====
\n
";
$filterStr
=~
s/\(|\)//gm
;
$filterStr
=~
s/=/: /m
;
my
@match_dn
=
();
for
my
$dn
(
keys
%
{
$this
}
)
{
if
(
$this
->
{
$dn
}
=~
/$filterStr/imx
)
{
push
@match_dn
,
$dn
;
last
if
(
scalar
@match_dn
==
$sizeLim
);
my
@match_dn
=
();
foreach
my
$dn
(
keys
%$this
)
{
if
(
$this
->
{
$dn
}
=~
/$filterStr/im
)
{
push
@match_dn
,
$dn
;
last
if
(
scalar
@match_dn
==
$sizeLim
);
}
}
}
}
my
@match_entries
=
();
my
@match_entries
=
();
foreach
my
$dn
(
@match_dn
)
{
push
@match_entries
,
$this
->
{
$dn
};
}
for
my
$dn
(
@match_dn
)
{
push
@match_entries
,
$this
->
{
$dn
};
}
return
(
0
,
@match_entries
);
return
(
0
,
@match_entries
);
}
sub
compare
{
my
$this
=
shift
;
my
(
$dn
,
$avaStr
)
=
@_
;
my
$rc
=
5
;
# LDAP_COMPARE_FALSE
sub
compare
{
my
$this
=
shift
;
my
(
$dn
,
$avaStr
)
=
@_
;
my
$rc
=
5
;
# LDAP_COMPARE_FALSE
$avaStr
=~
s/=/: /
;
$avaStr
=~
s/=/: /
m
;
if
(
$this
->
{
$dn
}
=~
/$avaStr/im
)
{
$rc
=
6
;
# LDAP_COMPARE_TRUE
}
if
(
$this
->
{
$dn
}
=~
/$avaStr/im
)
{
$rc
=
6
;
# LDAP_COMPARE_TRUE
}
return
$rc
;
return
$rc
;
}
sub
modify
{
my
$this
=
shift
;
sub
modify
{
my
$this
=
shift
;
my
(
$dn
,
@list
)
=
@_
;
my
(
$dn
,
@list
)
=
@_
;
while
(
@list
>
0
)
{
my
$action
=
shift
@list
;
my
$key
=
shift
@list
;
my
$value
=
shift
@list
;
while
(
@list
>
0
)
{
my
$action
=
shift
@list
;
my
$key
=
shift
@list
;
my
$value
=
shift
@list
;
if
(
$action
eq
"
ADD
"
)
{
$this
->
{
$dn
}
.=
"
$key
:
$value
\n
";
if
(
$action
eq
'
ADD
'
)
{
$this
->
{
$dn
}
.=
"
$key
:
$value
\n
";
}
elsif
(
$action
eq
"
DELETE
"
)
{
$this
->
{
$dn
}
=~
s/^$key:\s*$value\n//m
i
;
}
elsif
(
$action
eq
'
DELETE
'
)
{
$this
->
{
$dn
}
=~
s/^$key:\s*$value\n//
i
m
;
}
elsif
(
$action
eq
"
REPLACE
"
)
{
$this
->
{
$dn
}
=~
s/$key: .*$/$key: $value/im
;
}
}
}
elsif
(
$action
eq
'
REPLACE
'
)
{
$this
->
{
$dn
}
=~
s/$key: .*$/$key: $value/im
;
}
}
return
0
;
return
0
;
}
sub
add
{
my
$this
=
shift
;
sub
add
{
my
$this
=
shift
;
my
(
$entryStr
)
=
@_
;
my
(
$entryStr
)
=
@_
;
my
(
$dn
)
=
(
$entryStr
=~
/dn:\s(.*)$/m
);
my
(
$dn
)
=
(
$entryStr
=~
/dn:\s(.*)$/m
);
#
# This needs to be here until a normalized dn is
# passed to this routine.
#
$dn
=
uc
(
$dn
)
;
$dn
=~
s/\s*//g
;
#
# This needs to be here until a normalized dn is
# passed to this routine.
#
$dn
=
uc
$dn
;
$dn
=~
s/\s*//g
m
;
$this
->
{
$dn
}
=
$entryStr
;
$this
->
{
$dn
}
=
$entryStr
;
return
0
;
return
0
;
}
sub
modrdn
{
my
$this
=
shift
;
sub
modrdn
{
my
$this
=
shift
;
my
(
$dn
,
$newdn
,
$delFlag
)
=
@_
;
my
(
$dn
,
$newdn
,
$delFlag
)
=
@_
;
$this
->
{
$newdn
}
=
$this
->
{
$dn
};
$this
->
{
$newdn
}
=
$this
->
{
$dn
};
if
(
$delFlag
)
{
delete
$this
->
{
$dn
};
}
return
0
;
if
(
$delFlag
)
{
delete
$this
->
{
$dn
};
}
return
0
;
}
sub
delete
{
my
$this
=
shift
;
sub
delete
{
my
$this
=
shift
;
my
(
$dn
)
=
@_
;
my
(
$dn
)
=
@_
;
print
STDERR
"
XXXXXX
$dn
XXXXXXX
\n
";
delete
$this
->
{
$dn
};
print
<
STDERR
>
,
"
XXXXXX
$dn
XXXXXXX
\n
";
delete
$this
->
{
$dn
};
return
0
;
}
sub
config
{
my
$this
=
shift
;
sub
config
{
my
$this
=
shift
;
my
(
@args
)
=
@_
;
local
$,
=
"
-
"
;
print
STDERR
@args
;
print
STDERR
"
\n
";
return
0
;
my
(
@args
)
=
@_
;
local
$,
=
'
-
'
;
print
<
STDERR
>
,
@args
;
print
<
STDERR
>
,
"
\n
";
return
0
;
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment