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
Dragoș Haiduc
OpenLDAP
Commits
2d1b255c
Commit
2d1b255c
authored
17 years ago
by
Quanah Gibson-Mount
Browse files
Options
Downloads
Patches
Plain Diff
moved ldap_result() code to the LDAPRequest-Class
parent
a655210a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/ldapc++/src/LDAPMessageQueue.cpp
+85
-98
85 additions, 98 deletions
contrib/ldapc++/src/LDAPMessageQueue.cpp
contrib/ldapc++/src/LDAPRequest.cpp
+23
-0
23 additions, 0 deletions
contrib/ldapc++/src/LDAPRequest.cpp
contrib/ldapc++/src/LDAPRequest.h
+1
-0
1 addition, 0 deletions
contrib/ldapc++/src/LDAPRequest.h
with
109 additions
and
98 deletions
contrib/ldapc++/src/LDAPMessageQueue.cpp
+
85
−
98
View file @
2d1b255c
...
...
@@ -6,10 +6,8 @@
#include
"config.h"
#include
"debug.h"
#include
<ldap.h>
#include
"LDAPMessageQueue.h"
#include
"LDAPRequest.h"
#include
"LDAPAsynConnection.h"
#include
"LDAPResult.h"
#include
"LDAPSearchReference.h"
#include
"LDAPSearchRequest.h"
...
...
@@ -40,110 +38,99 @@ LDAPMessageQueue::~LDAPMessageQueue(){
LDAPMsg
*
LDAPMessageQueue
::
getNext
(){
DEBUG
(
LDAP_DEBUG_TRACE
,
"LDAPMessageQueue::getNext()"
<<
endl
);
LDAPMessage
*
msg
;
LDAPRequest
*
req
=
m_activeReq
.
top
();
int
msg_id
=
req
->
getMsgID
();
int
res
;
const
LDAPAsynConnection
*
con
=
req
->
getConnection
();
res
=
ldap_result
(
con
->
getSessionHandle
(),
msg_id
,
0
,
0
,
&
msg
);
if
(
res
<=
0
){
if
(
msg
!=
0
){
ldap_msgfree
(
msg
);
}
throw
LDAPException
(
con
);
}
else
{
const
LDAPConstraints
*
constr
=
req
->
getConstraints
();
LDAPMsg
*
ret
=
0
;
//this can throw an exception (Decoding Error)
try
{
ret
=
LDAPMsg
::
create
(
req
,
msg
);
ldap_msgfree
(
msg
);
}
catch
(
LDAPException
e
){
//do some clean up
delete
req
;
m_activeReq
.
top
();
throw
;
}
switch
(
ret
->
getMessageType
())
{
case
LDAPMsg
::
SEARCH_REFERENCE
:
if
(
constr
->
getReferralChase
()
){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
}
return
ret
;
break
;
case
LDAPMsg
::
SEARCH_ENTRY
:
return
ret
;
break
;
case
LDAPMsg
::
SEARCH_DONE
:
if
(
req
->
isReferral
()){
req
->
unbind
();
LDAPMsg
*
ret
=
0
;
try
{
ret
=
req
->
getNextMessage
();
}
catch
(
LDAPException
e
){
//do some clean up
delete
req
;
m_activeReq
.
top
();
throw
;
}
const
LDAPConstraints
*
constr
=
req
->
getConstraints
();
switch
(
ret
->
getMessageType
())
{
case
LDAPMsg
::
SEARCH_REFERENCE
:
if
(
constr
->
getReferralChase
()
){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
switch
(
((
LDAPResult
*
)
ret
)
->
getResultCode
())
{
case
LDAPResult
::
REFERRAL
:
if
(
constr
->
getReferralChase
()){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
pop
();
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
}
return
ret
;
break
;
case
LDAPResult
::
SUCCESS
:
if
(
req
->
isReferral
()){
delete
ret
;
}
return
ret
;
break
;
case
LDAPMsg
::
SEARCH_ENTRY
:
return
ret
;
break
;
case
LDAPMsg
::
SEARCH_DONE
:
if
(
req
->
isReferral
()){
req
->
unbind
();
}
switch
(
((
LDAPResult
*
)
ret
)
->
getResultCode
())
{
case
LDAPResult
::
REFERRAL
:
if
(
constr
->
getReferralChase
()){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
pop
();
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
else
{
m_activeReq
.
pop
();
return
ret
;
}
break
;
default
:
}
return
ret
;
break
;
case
LDAPResult
::
SUCCESS
:
if
(
req
->
isReferral
()){
delete
ret
;
m_activeReq
.
pop
();
return
ret
;
break
;
}
break
;
//must be some kind of LDAPResultMessage
default
:
if
(
req
->
isReferral
()){
req
->
unbind
();
}
LDAPResult
*
res_p
=
(
LDAPResult
*
)
ret
;
switch
(
res_p
->
getResultCode
())
{
case
LDAPResult
::
REFERRAL
:
if
(
constr
->
getReferralChase
()){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
pop
();
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
}
return
ret
;
break
;
default
:
return
getNext
();
}
else
{
m_activeReq
.
pop
();
return
ret
;
}
break
;
}
}
}
break
;
default
:
m_activeReq
.
pop
();
return
ret
;
break
;
}
break
;
//must be some kind of LDAPResultMessage
default
:
if
(
req
->
isReferral
()){
req
->
unbind
();
}
LDAPResult
*
res_p
=
(
LDAPResult
*
)
ret
;
switch
(
res_p
->
getResultCode
())
{
case
LDAPResult
::
REFERRAL
:
if
(
constr
->
getReferralChase
()){
//throws Exception (limit Exceeded)
LDAPRequest
*
refReq
=
chaseReferral
(
ret
);
if
(
refReq
!=
0
){
m_activeReq
.
pop
();
m_activeReq
.
push
(
refReq
);
m_issuedReq
.
push_back
(
refReq
);
delete
ret
;
return
getNext
();
}
}
return
ret
;
break
;
default
:
m_activeReq
.
pop
();
return
ret
;
}
break
;
}
}
// TODO Maybe moved to LDAPRequest::followReferral seems more reasonable
...
...
This diff is collapsed.
Click to expand it.
contrib/ldapc++/src/LDAPRequest.cpp
+
23
−
0
View file @
2d1b255c
...
...
@@ -47,6 +47,29 @@ LDAPRequest::~LDAPRequest(){
delete
m_cons
;
}
LDAPMsg
*
LDAPRequest
::
getNextMessage
()
const
{
DEBUG
(
LDAP_DEBUG_DESTROY
,
"LDAPRequest::getNextMessage()"
<<
endl
);
int
res
;
LDAPMessage
*
msg
;
res
=
ldap_result
(
this
->
m_connection
->
getSessionHandle
(),
this
->
m_msgID
,
0
,
0
,
&
msg
);
if
(
res
<=
0
){
if
(
msg
!=
0
){
ldap_msgfree
(
msg
);
}
throw
LDAPException
(
this
->
m_connection
);
}
else
{
LDAPMsg
*
ret
=
0
;
//this can throw an exception (Decoding Error)
ret
=
LDAPMsg
::
create
(
this
,
msg
);
ldap_msgfree
(
msg
);
return
ret
;
}
}
const
LDAPConstraints
*
LDAPRequest
::
getConstraints
()
const
{
DEBUG
(
LDAP_DEBUG_TRACE
,
"LDAPRequest::getConstraints()"
<<
endl
);
return
m_cons
;
...
...
This diff is collapsed.
Click to expand it.
contrib/ldapc++/src/LDAPRequest.h
+
1
−
0
View file @
2d1b255c
...
...
@@ -40,6 +40,7 @@ class LDAPRequest{
const
LDAPConstraints
*
getConstraints
()
const
;
const
LDAPAsynConnection
*
getConnection
()
const
;
LDAPMsg
*
getNextMessage
()
const
;
int
getType
()
const
;
int
getMsgID
()
const
;
int
getHopCount
()
const
;
...
...
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