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
James Rouzier
OpenLDAP
Commits
b16e25ba
Commit
b16e25ba
authored
19 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
import tool_perror
parent
5840b989
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
clients/tools/common.c
+62
-14
62 additions, 14 deletions
clients/tools/common.c
clients/tools/common.h
+7
-0
7 additions, 0 deletions
clients/tools/common.h
with
69 additions
and
14 deletions
clients/tools/common.c
+
62
−
14
View file @
b16e25ba
...
...
@@ -188,6 +188,34 @@ NULL
}
}
void
tool_perror
(
char
*
func
,
int
err
,
char
*
extra
,
char
*
matched
,
char
*
info
,
char
**
refs
)
{
fprintf
(
stderr
,
"%s: %s (%d)%s
\n
"
,
func
,
ldap_err2string
(
err
),
err
,
extra
?
extra
:
""
);
if
(
matched
&&
*
matched
)
{
fprintf
(
stderr
,
_
(
"
\t
matched DN: %s
\n
"
),
matched
);
}
if
(
info
&&
*
info
)
{
fprintf
(
stderr
,
_
(
"
\t
additional info: %s
\n
"
),
info
);
}
if
(
refs
&&
*
refs
)
{
int
i
;
fprintf
(
stderr
,
_
(
"
\t
referrals:
\n
"
)
);
for
(
i
=
0
;
refs
[
i
];
i
++
)
{
fprintf
(
stderr
,
"
\t\t
%s
\n
"
,
refs
[
i
]
);
}
}
}
void
tool_args
(
int
argc
,
char
**
argv
)
...
...
@@ -931,11 +959,14 @@ tool_bind( LDAP *ld )
LDAPMessage
*
result
;
LDAPControl
**
ctrls
;
char
msgbuf
[
256
];
char
*
matched
=
NULL
;
char
*
info
=
NULL
;
char
**
refs
=
NULL
;
msgbuf
[
0
]
=
0
;
if
((
msgid
=
ldap_bind
(
ld
,
binddn
,
passwd
.
bv_val
,
authmethod
)
)
==
-
1
)
{
msgid
=
ldap_bind
(
ld
,
binddn
,
passwd
.
bv_val
,
authmethod
)
;
if
(
msgid
==
-
1
)
{
ldap_perror
(
ld
,
"ldap_bind"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -945,8 +976,9 @@ tool_bind( LDAP *ld )
exit
(
EXIT_FAILURE
);
}
if
(
ldap_parse_result
(
ld
,
result
,
&
err
,
NULL
,
NULL
,
NULL
,
&
ctrls
,
1
)
!=
LDAP_SUCCESS
)
{
if
(
ldap_parse_result
(
ld
,
result
,
&
err
,
&
matched
,
&
info
,
&
refs
,
&
ctrls
,
1
)
!=
LDAP_SUCCESS
)
{
ldap_perror
(
ld
,
"ldap_bind parse result"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -957,9 +989,12 @@ tool_bind( LDAP *ld )
int
expire
,
grace
,
len
=
0
;
LDAPPasswordPolicyError
pErr
=
-
1
;
ctrl
=
ldap_find_control
(
LDAP_CONTROL_PASSWORDPOLICYRESPONSE
,
ctrls
);
ctrl
=
ldap_find_control
(
LDAP_CONTROL_PASSWORDPOLICYRESPONSE
,
ctrls
);
if
(
ctrl
&&
ldap_parse_passwordpolicy_control
(
ld
,
ctrl
,
&
expire
,
&
grace
,
&
pErr
)
==
LDAP_SUCCESS
)
{
&
expire
,
&
grace
,
&
pErr
)
==
LDAP_SUCCESS
)
{
if
(
pErr
!=
PP_noError
){
msgbuf
[
0
]
=
';'
;
msgbuf
[
1
]
=
' '
;
...
...
@@ -967,22 +1002,35 @@ tool_bind( LDAP *ld )
len
=
strlen
(
msgbuf
);
}
if
(
expire
>=
0
)
{
sprintf
(
msgbuf
+
len
,
" (Password expires in %d seconds)"
,
expire
);
sprintf
(
msgbuf
+
len
,
" (Password expires in %d seconds)"
,
expire
);
}
else
if
(
grace
>=
0
)
{
sprintf
(
msgbuf
+
len
,
" (Password expired, %d grace logins remain)"
,
grace
);
sprintf
(
msgbuf
+
len
,
" (Password expired, %d grace logins remain)"
,
grace
);
}
}
}
#endif
if
(
ctrls
)
{
ldap_controls_free
(
ctrls
);
}
if
(
err
!=
LDAP_SUCCESS
||
msgbuf
[
0
]
)
{
fprintf
(
stderr
,
"ldap_bind: %s%s
\n
"
,
ldap_err2string
(
err
),
msgbuf
);
if
(
err
!=
LDAP_SUCCESS
)
{
exit
(
EXIT_FAILURE
);
}
if
(
err
!=
LDAP_SUCCESS
||
msgbuf
[
0
]
||
(
matched
&&
matched
[
0
]
)
||
(
info
&&
info
[
0
]
)
||
refs
)
{
tool_perror
(
"ldap_bind"
,
err
,
msgbuf
,
matched
,
info
,
refs
);
if
(
matched
)
ber_memfree
(
matched
);
if
(
info
)
ber_memfree
(
info
);
if
(
refs
)
ber_memvfree
(
(
void
**
)
refs
);
if
(
err
!=
LDAP_SUCCESS
)
exit
(
EXIT_FAILURE
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
clients/tools/common.h
+
7
−
0
View file @
b16e25ba
...
...
@@ -82,6 +82,13 @@ void tool_unbind LDAP_P(( LDAP * ));
void
tool_destroy
LDAP_P
((
void
));
void
tool_server_controls
LDAP_P
((
LDAP
*
,
LDAPControl
*
,
int
));
int
tool_check_abandon
LDAP_P
((
LDAP
*
ld
,
int
msgid
));
void
tool_perror
LDAP_P
((
char
*
func
,
int
err
,
char
*
extra
,
char
*
matched
,
char
*
info
,
char
**
refs
));
LDAP_END_DECL
...
...
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