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
48c8aa03
Commit
48c8aa03
authored
25 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
EXPERIMENTAL ldap_extended_operation() and ldap_parse_extended_result()
parent
0c8f1d24
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
include/ldap.h
+4
-4
4 additions, 4 deletions
include/ldap.h
libraries/libldap/extended.c
+192
-6
192 additions, 6 deletions
libraries/libldap/extended.c
with
196 additions
and
10 deletions
include/ldap.h
+
4
−
4
View file @
48c8aa03
...
...
@@ -548,8 +548,8 @@ ldap_controls_free LDAP_P((
LDAP_F
(
int
)
ldap_extended_operation
LDAP_P
((
LDAP
*
ld
,
LDAP_CONST
char
*
ex
oid
,
struct
berval
*
ex
data
,
LDAP_CONST
char
*
req
oid
,
struct
berval
*
req
data
,
LDAPControl
**
serverctrls
,
LDAPControl
**
clientctrls
,
int
*
msgidp
));
...
...
@@ -557,8 +557,8 @@ ldap_extended_operation LDAP_P((
LDAP_F
(
int
)
ldap_extended_operation_s
LDAP_P
((
LDAP
*
ld
,
LDAP_CONST
char
*
ex
oid
,
struct
berval
*
ex
data
,
LDAP_CONST
char
*
req
oid
,
struct
berval
*
req
data
,
LDAPControl
**
serverctrls
,
LDAPControl
**
clientctrls
,
char
**
retoidp
,
...
...
This diff is collapsed.
Click to expand it.
libraries/libldap/extended.c
+
192
−
6
View file @
48c8aa03
...
...
@@ -33,27 +33,213 @@
int
ldap_extended_operation
(
LDAP
*
ld
,
LDAP_CONST
char
*
ex
oid
,
struct
berval
*
ex
data
,
LDAP_CONST
char
*
req
oid
,
struct
berval
*
req
data
,
LDAPControl
**
sctrls
,
LDAPControl
**
cctrls
,
int
*
msgidp
)
{
BerElement
*
ber
;
Debug
(
LDAP_DEBUG_TRACE
,
"ldap_extended_operation
\n
"
,
0
,
0
,
0
);
return
LDAP_NOT_SUPPORTED
;
assert
(
ld
!=
NULL
);
assert
(
LDAP_VALID
(
ld
)
);
assert
(
reqoid
!=
NULL
||
*
reqoid
==
'\0'
);
assert
(
msgidp
!=
NULL
);
/* must be version 3 (or greater) */
if
(
ld
->
ld_version
==
0
)
{
ld
->
ld_version
=
LDAP_VERSION3
;
}
if
(
ld
->
ld_version
<
LDAP_VERSION3
)
{
ld
->
ld_errno
=
LDAP_NOT_SUPPORTED
;
return
(
ld
->
ld_errno
);
}
if
(
reqoid
==
NULL
||
*
reqoid
==
'\0'
||
msgidp
==
NULL
)
{
ld
->
ld_errno
=
LDAP_PARAM_ERROR
;
return
(
ld
->
ld_errno
);
}
/* create a message to send */
if
(
(
ber
=
ldap_alloc_ber_with_options
(
ld
))
==
NULLBER
)
{
ld
->
ld_errno
=
LDAP_NO_MEMORY
;
return
(
ld
->
ld_errno
);
}
if
(
ber_printf
(
ber
,
"{it{tstO}"
,
/* leave '}' for later */
++
ld
->
ld_msgid
,
LDAP_REQ_EXTENDED
,
LDAP_TAG_EXOP_REQ_OID
,
reqoid
,
LDAP_TAG_EXOP_REQ_VALUE
,
reqdata
)
==
-
1
)
{
ld
->
ld_errno
=
LDAP_ENCODING_ERROR
;
ber_free
(
ber
,
1
);
return
(
ld
->
ld_errno
);
}
/* Put Server Controls */
if
(
ldap_int_put_controls
(
ld
,
sctrls
,
ber
)
!=
LDAP_SUCCESS
)
{
ber_free
(
ber
,
1
);
return
ld
->
ld_errno
;
}
if
(
ber_printf
(
ber
,
/*{*/
"}"
)
==
-
1
)
{
ld
->
ld_errno
=
LDAP_ENCODING_ERROR
;
ber_free
(
ber
,
1
);
return
(
ld
->
ld_errno
);
}
/* send the message */
*
msgidp
=
ldap_send_initial_request
(
ld
,
LDAP_REQ_EXTENDED
,
NULL
,
ber
);
return
(
*
msgidp
<
0
?
ld
->
ld_errno
:
LDAP_SUCCESS
);
}
int
ldap_extended_operation_s
(
LDAP
*
ld
,
LDAP_CONST
char
*
ex
oid
,
struct
berval
*
ex
data
,
LDAP_CONST
char
*
req
oid
,
struct
berval
*
req
data
,
LDAPControl
**
sctrls
,
LDAPControl
**
cctrls
,
char
**
retoidp
,
struct
berval
**
retdatap
)
{
int
rc
;
int
msgid
;
LDAPMessage
*
res
;
Debug
(
LDAP_DEBUG_TRACE
,
"ldap_extended_operation_s
\n
"
,
0
,
0
,
0
);
return
LDAP_NOT_SUPPORTED
;
assert
(
ld
!=
NULL
);
assert
(
LDAP_VALID
(
ld
)
);
assert
(
reqoid
!=
NULL
||
*
reqoid
==
'\0'
);
assert
(
retoidp
!=
NULL
||
retdatap
!=
NULL
);
if
(
retoidp
==
NULL
||
retdatap
==
NULL
)
{
ld
->
ld_errno
=
LDAP_PARAM_ERROR
;
return
(
ld
->
ld_errno
);
}
rc
=
ldap_extended_operation
(
ld
,
reqoid
,
reqdata
,
sctrls
,
cctrls
,
&
msgid
);
if
(
rc
!=
LDAP_SUCCESS
)
{
return
(
rc
);
}
if
(
ldap_result
(
ld
,
msgid
,
1
,
(
struct
timeval
*
)
NULL
,
&
res
)
==
-
1
)
{
return
(
ld
->
ld_errno
);
}
*
retoidp
=
NULL
;
*
retdatap
=
NULL
;
rc
=
ldap_parse_extended_result
(
ld
,
res
,
retoidp
,
retdatap
,
0
);
if
(
rc
!=
LDAP_SUCCESS
)
{
ldap_msgfree
(
res
);
return
rc
;
}
return
(
ldap_result2error
(
ld
,
res
,
1
)
);
}
/* Parse an extended result */
int
ldap_parse_extended_result
(
LDAP
*
ld
,
LDAPMessage
*
res
,
char
**
retoidp
,
struct
berval
**
retdatap
,
int
freeit
)
{
BerElement
*
ber
;
int
rc
;
unsigned
long
tag
,
len
;
struct
berval
*
resdata
;
long
errcode
;
char
*
resoid
;
assert
(
ld
!=
NULL
);
assert
(
LDAP_VALID
(
ld
)
);
assert
(
res
!=
NULL
);
Debug
(
LDAP_DEBUG_TRACE
,
"ldap_parse_extended_result
\n
"
,
0
,
0
,
0
);
if
(
ld
->
ld_version
<
LDAP_VERSION3
)
{
ld
->
ld_errno
=
LDAP_NOT_SUPPORTED
;
return
ld
->
ld_errno
;
}
if
(
retoidp
!=
NULL
)
*
retoidp
=
NULL
;
if
(
retdatap
!=
NULL
)
*
retdatap
=
NULL
;
ber
=
ber_dup
(
res
->
lm_ber
);
if
(
ld
->
ld_error
)
{
LDAP_FREE
(
ld
->
ld_error
);
ld
->
ld_error
=
NULL
;
}
if
(
ld
->
ld_matched
)
{
LDAP_FREE
(
ld
->
ld_matched
);
ld
->
ld_matched
=
NULL
;
}
rc
=
ber_scanf
(
ber
,
"{iaa"
,
&
errcode
,
&
ld
->
ld_matched
,
&
ld
->
ld_matched
);
if
(
rc
==
LBER_ERROR
)
{
ld
->
ld_errno
=
LDAP_DECODING_ERROR
;
ber_free
(
ber
,
0
);
return
ld
->
ld_errno
;
}
resoid
=
NULL
;
resdata
=
NULL
;
tag
=
ber_peek_tag
(
ber
,
&
len
);
if
(
tag
==
LDAP_TAG_EXOP_RES_OID
)
{
/* we have a resoid */
if
(
ber_scanf
(
ber
,
"a"
,
&
resoid
)
==
LBER_ERROR
)
{
ld
->
ld_errno
=
LDAP_DECODING_ERROR
;
ber_free
(
ber
,
0
);
return
ld
->
ld_errno
;
}
tag
=
ber_peek_tag
(
ber
,
&
len
);
}
if
(
tag
==
LDAP_TAG_EXOP_RES_VALUE
)
{
/* we have a resdata */
if
(
ber_scanf
(
ber
,
"O"
,
&
resoid
)
==
LBER_ERROR
)
{
ld
->
ld_errno
=
LDAP_DECODING_ERROR
;
ber_free
(
ber
,
0
);
if
(
resoid
!=
NULL
)
LDAP_FREE
(
resoid
);
return
ld
->
ld_errno
;
}
}
if
(
retoidp
!=
NULL
)
{
*
retoidp
=
resoid
;
}
else
{
LDAP_FREE
(
resoid
);
}
if
(
retdatap
!=
NULL
)
{
*
retdatap
=
resdata
;
}
else
{
ber_bvfree
(
resdata
);
}
ld
->
ld_errno
=
errcode
;
if
(
freeit
)
{
ldap_msgfree
(
res
);
}
return
LDAP_SUCCESS
;
}
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