Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Joe Martin
OpenLDAP
Commits
2c8790aa
Commit
2c8790aa
authored
19 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Add -F force option to continue after bind failures. Use gettimeofday
for better timing resolution.
parent
a88bfa6a
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
tests/progs/slapd-bind.c
+33
-14
33 additions, 14 deletions
tests/progs/slapd-bind.c
with
33 additions
and
14 deletions
tests/progs/slapd-bind.c
+
33
−
14
View file @
2c8790aa
...
...
@@ -30,6 +30,7 @@
#include
<ac/string.h>
#include
<ac/unistd.h>
#include
<ac/wait.h>
#include
<ac/time.h>
#define LDAP_DEPRECATED 1
#include
<ldap.h>
...
...
@@ -38,10 +39,12 @@
#define LOOPS 100
static
int
do_bind
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
dn
,
char
*
pass
,
int
maxloop
);
do_bind
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
dn
,
char
*
pass
,
int
maxloop
,
int
force
);
static
int
do_base
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
base
,
char
*
pass
,
int
maxloop
);
do_base
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
base
,
char
*
pass
,
int
maxloop
,
int
force
);
/* This program can be invoked two ways: if -D is used to specify a Bind DN,
* that DN will be used repeatedly for all of the Binds. If instead -b is used
...
...
@@ -53,7 +56,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop );
static
void
usage
(
char
*
name
)
{
fprintf
(
stderr
,
"usage: %s [-h <host>] -p port (-D <dn>|-b <baseDN> [-f <searchfilter>]) -w <passwd> [-l <loops>]
\n
"
,
fprintf
(
stderr
,
"usage: %s [-h <host>] -p port (-D <dn>|-b <baseDN> [-f <searchfilter>]) -w <passwd> [-l <loops>]
[-F]
\n
"
,
name
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -71,8 +74,9 @@ main( int argc, char **argv )
char
*
pass
=
NULL
;
int
port
=
-
1
;
int
loops
=
LOOPS
;
int
force
=
0
;
while
(
(
i
=
getopt
(
argc
,
argv
,
"b:H:h:p:D:w:l:f:"
))
!=
EOF
)
{
while
(
(
i
=
getopt
(
argc
,
argv
,
"b:H:h:p:D:w:l:f:
F
"
))
!=
EOF
)
{
switch
(
i
)
{
case
'b'
:
/* base DN of a tree of user DNs */
base
=
strdup
(
optarg
);
...
...
@@ -105,6 +109,10 @@ main( int argc, char **argv )
filter
=
optarg
;
break
;
case
'F'
:
force
=
1
;
break
;
default:
usage
(
argv
[
0
]
);
break
;
...
...
@@ -115,15 +123,16 @@ main( int argc, char **argv )
usage
(
argv
[
0
]
);
if
(
base
)
do_base
(
uri
,
host
,
port
,
base
,
pass
,
(
20
*
loops
));
do_base
(
uri
,
host
,
port
,
base
,
pass
,
(
20
*
loops
)
,
force
);
else
do_bind
(
uri
,
host
,
port
,
dn
,
pass
,
(
20
*
loops
));
do_bind
(
uri
,
host
,
port
,
dn
,
pass
,
(
20
*
loops
)
,
force
);
exit
(
EXIT_SUCCESS
);
}
static
int
do_bind
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
dn
,
char
*
pass
,
int
maxloop
)
do_bind
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
dn
,
char
*
pass
,
int
maxloop
,
int
force
)
{
LDAP
*
ld
=
NULL
;
int
i
,
rc
=
-
1
;
...
...
@@ -156,7 +165,7 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop )
ldap_perror
(
ld
,
"ldap_bind"
);
}
ldap_unbind
(
ld
);
if
(
rc
!=
LDAP_SUCCESS
)
{
if
(
rc
!=
LDAP_SUCCESS
&&
!
force
)
{
break
;
}
}
...
...
@@ -169,7 +178,8 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop )
static
int
do_base
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
base
,
char
*
pass
,
int
maxloop
)
do_base
(
char
*
uri
,
char
*
host
,
int
port
,
char
*
base
,
char
*
pass
,
int
maxloop
,
int
force
)
{
LDAP
*
ld
=
NULL
;
int
i
=
0
;
...
...
@@ -180,7 +190,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
char
**
rdns
=
NULL
;
char
*
attrs
[]
=
{
"dn"
,
NULL
};
int
nrdns
=
0
;
time
_t
beg
,
end
;
struct
time
val
beg
,
end
;
srand
(
pid
);
...
...
@@ -246,12 +256,13 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
}
ldap_unbind
(
ld
);
gettimeofday
(
&
beg
,
NULL
);
if
(
nrdns
==
0
)
{
fprintf
(
stderr
,
"No RDNs.
\n
"
);
return
1
;
}
beg
=
time
(
0L
);
/* Ok, got list of RDNs, now start binding to each */
for
(
i
=
0
;
i
<
maxloop
;
i
++
)
{
char
dn
[
BUFSIZ
],
*
ptr
;
...
...
@@ -259,10 +270,18 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
ptr
=
lutil_strcopy
(
dn
,
rdns
[
j
]);
*
ptr
++
=
','
;
strcpy
(
ptr
,
base
);
if
(
do_bind
(
uri
,
host
,
port
,
dn
,
pass
,
1
)
)
if
(
do_bind
(
uri
,
host
,
port
,
dn
,
pass
,
1
,
force
)
&&
!
force
)
break
;
}
end
=
time
(
0L
);
fprintf
(
stderr
,
"Done %d Binds in %d seconds.
\n
"
,
i
,
end
-
beg
);
gettimeofday
(
&
end
,
NULL
);
end
.
tv_usec
-=
beg
.
tv_usec
;
if
(
end
.
tv_usec
<
0
)
{
end
.
tv_usec
+=
1000000
;
end
.
tv_sec
-=
1
;
}
end
.
tv_sec
-=
beg
.
tv_sec
;
fprintf
(
stderr
,
"Done %d Binds in %d.%06d seconds.
\n
"
,
i
,
end
.
tv_sec
,
end
.
tv_usec
);
return
0
;
}
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