Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
openldap
OpenLDAP
Commits
0cc024a3
Commit
0cc024a3
authored
Dec 02, 2004
by
Pierangelo Masarati
Browse files
more on DN munging; now works for all operations
parent
396743f6
Changes
10
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-sql/add.c
View file @
0cc024a3
...
...
@@ -908,9 +908,7 @@ backsql_add( Operation *op, SlapReply *rs )
Attribute
*
at
,
*
at_objectClass
=
NULL
;
struct
berval
pdn
;
struct
berval
realdn
=
BER_BVNULL
,
realndn
=
BER_BVNULL
,
realpdn
=
BER_BVNULL
;
struct
berval
realdn
=
BER_BVNULL
;
#ifdef BACKSQL_SYNCPROV
/*
...
...
@@ -1018,17 +1016,7 @@ backsql_add( Operation *op, SlapReply *rs )
goto
done
;
}
realndn
=
op
->
oq_add
.
rs_e
->
e_nname
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add(
\"
%s
\"
): "
"backsql_api_dn2odbc(
\"
%s
\"
) failed
\n
"
,
op
->
oq_add
.
rs_e
->
e_name
.
bv_val
,
realndn
.
bv_val
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
goto
done
;
}
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
NULL
,
dbh
,
&
realndn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
NULL
,
dbh
,
&
realdn
,
0
);
if
(
rs
->
sr_err
==
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add(
\"
%s
\"
): "
"entry exists
\n
"
,
...
...
@@ -1047,17 +1035,7 @@ backsql_add( Operation *op, SlapReply *rs )
dnParent
(
&
op
->
oq_add
.
rs_e
->
e_nname
,
&
pdn
);
}
realpdn
=
pdn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realpdn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add(
\"
%s
\"
): "
"backsql_api_dn2odbc(
\"
%s
\"
) failed
\n
"
,
op
->
oq_add
.
rs_e
->
e_name
.
bv_val
,
pdn
.
bv_val
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
goto
done
;
}
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
parent_id
,
dbh
,
&
realpdn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
parent_id
,
dbh
,
&
pdn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add(
\"
%s
\"
): "
"could not lookup parent entry for new record
\"
%s
\"\n
"
,
...
...
@@ -1085,28 +1063,13 @@ backsql_add( Operation *op, SlapReply *rs )
struct
berval
dn
;
char
*
matched
=
NULL
;
if
(
realpdn
.
bv_val
!=
pdn
.
bv_val
)
{
ch_free
(
realpdn
.
bv_val
);
}
dn
=
pdn
;
dnParent
(
&
dn
,
&
pdn
);
/*
* Empty DN ("") defaults to LDAP_SUCCESS
*/
realpdn
=
pdn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realpdn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add(
\"
%s
\"
): "
"backsql_api_dn2odbc failed
\n
"
,
op
->
oq_add
.
rs_e
->
e_name
.
bv_val
,
0
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
goto
done
;
}
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
NULL
,
dbh
,
&
realpdn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
NULL
,
dbh
,
&
pdn
,
1
);
switch
(
rs
->
sr_err
)
{
case
LDAP_NO_SUCH_OBJECT
:
if
(
!
BER_BVISEMPTY
(
&
pdn
)
)
{
...
...
@@ -1444,14 +1407,6 @@ done:;
{
ch_free
(
realdn
.
bv_val
);
}
if
(
!
BER_BVISNULL
(
&
realndn
)
&&
realndn
.
bv_val
!=
op
->
oq_add
.
rs_e
->
e_nname
.
bv_val
)
{
ch_free
(
realndn
.
bv_val
);
}
if
(
!
BER_BVISNULL
(
&
realpdn
)
&&
realpdn
.
bv_val
!=
pdn
.
bv_val
)
{
ch_free
(
realpdn
.
bv_val
);
}
if
(
!
BER_BVISNULL
(
&
parent_id
.
eid_ndn
)
)
{
(
void
)
backsql_free_entryID
(
&
parent_id
,
0
);
}
...
...
servers/slapd/back-sql/bind.c
View file @
0cc024a3
...
...
@@ -36,7 +36,6 @@ backsql_bind( Operation *op, SlapReply *rs )
backsql_srch_info
bsi
;
AttributeName
anlist
[
2
];
int
rc
;
struct
berval
ndn
;
Debug
(
LDAP_DEBUG_TRACE
,
"==>backsql_bind()
\n
"
,
0
,
0
,
0
);
...
...
@@ -71,22 +70,13 @@ backsql_bind( Operation *op, SlapReply *rs )
return
1
;
}
ndn
=
op
->
o_req_ndn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
ndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_search(): "
"backsql_api_dn2odbc failed
\n
"
,
0
,
0
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
goto
error_return
;
}
anlist
[
0
].
an_name
=
password
->
ad_cname
;
anlist
[
0
].
an_desc
=
password
;
anlist
[
1
].
an_name
.
bv_val
=
NULL
;
rc
=
backsql_init_search
(
&
bsi
,
&
ndn
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
anlist
,
1
);
rc
=
backsql_init_search
(
&
bsi
,
&
op
->
o_req_ndn
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
anlist
,
(
BACKSQL_ISF_GET_ID
|
BACKSQL_ISF_MUCK
)
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_bind(): "
"could not retrieve bindDN ID - no such entry
\n
"
,
...
...
@@ -141,10 +131,6 @@ error_return:;
return
1
;
}
if
(
ndn
.
bv_val
!=
op
->
o_req_ndn
.
bv_val
)
{
ch_free
(
ndn
.
bv_val
);
}
Debug
(
LDAP_DEBUG_TRACE
,
"<==backsql_bind()
\n
"
,
0
,
0
,
0
);
return
0
;
}
...
...
servers/slapd/back-sql/compare.c
View file @
0cc024a3
...
...
@@ -35,7 +35,6 @@ backsql_compare( Operation *op, SlapReply *rs )
backsql_srch_info
bsi
;
int
rc
;
AttributeName
anlist
[
2
];
struct
berval
ndn
;
user_entry
.
e_name
.
bv_val
=
NULL
;
user_entry
.
e_name
.
bv_len
=
0
;
...
...
@@ -56,16 +55,6 @@ backsql_compare( Operation *op, SlapReply *rs )
goto
return_results
;
}
ndn
=
op
->
o_req_ndn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
ndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_search(): "
"backsql_api_dn2odbc failed
\n
"
,
0
,
0
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
goto
return_results
;
}
memset
(
&
anlist
[
0
],
0
,
2
*
sizeof
(
AttributeName
)
);
anlist
[
0
].
an_name
=
op
->
oq_compare
.
rs_ava
->
aa_desc
->
ad_cname
;
anlist
[
0
].
an_desc
=
op
->
oq_compare
.
rs_ava
->
aa_desc
;
...
...
@@ -93,8 +82,9 @@ backsql_compare( Operation *op, SlapReply *rs )
user_entry
.
e_attrs
=
nrs
.
sr_operational_attrs
;
}
else
{
rc
=
backsql_init_search
(
&
bsi
,
&
ndn
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
anlist
,
1
);
rc
=
backsql_init_search
(
&
bsi
,
&
op
->
o_req_ndn
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
anlist
,
(
BACKSQL_ISF_GET_ID
|
BACKSQL_ISF_MUCK
)
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_compare(): "
"could not retrieve compareDN ID - no such entry
\n
"
,
...
...
@@ -147,10 +137,6 @@ return_results:;
(
void
)
backsql_free_entryID
(
&
bsi
.
bsi_base_id
,
0
);
}
if
(
ndn
.
bv_val
!=
op
->
o_req_ndn
.
bv_val
)
{
ch_free
(
ndn
.
bv_val
);
}
if
(
e
!=
NULL
)
{
entry_clean
(
e
);
}
...
...
servers/slapd/back-sql/delete.c
View file @
0cc024a3
...
...
@@ -118,8 +118,7 @@ backsql_delete( Operation *op, SlapReply *rs )
goto
done
;
}
/* FIXME: API... */
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_delete(): "
"could not lookup entry id
\n
"
,
0
,
0
,
0
);
...
...
servers/slapd/back-sql/entry-id.c
View file @
0cc024a3
...
...
@@ -80,13 +80,15 @@ backsql_dn2id(
SlapReply
*
rs
,
backsql_entryID
*
id
,
SQLHDBC
dbh
,
struct
berval
*
ndn
)
struct
berval
*
ndn
,
int
muck
)
{
backsql_info
*
bi
=
op
->
o_bd
->
be_private
;
SQLHSTMT
sth
;
SQLHSTMT
sth
=
SQL_NULL_HSTMT
;
BACKSQL_ROW_NTS
row
;
RETCODE
rc
;
int
res
;
struct
berval
realndn
=
BER_BVNULL
;
/* TimesTen */
char
upperdn
[
BACKSQL_MAX_DN_LEN
+
1
];
...
...
@@ -141,8 +143,19 @@ backsql_dn2id(
"backsql_dn2id(): error preparing SQL:
\n
%s"
,
bi
->
sql_id_query
,
0
,
0
);
backsql_PrintErrors
(
bi
->
sql_db_env
,
dbh
,
sth
,
rc
);
SQLFreeStmt
(
sth
,
SQL_DROP
);
return
LDAP_OTHER
;
res
=
LDAP_OTHER
;
goto
done
;
}
realndn
=
*
ndn
;
if
(
muck
)
{
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_dn2id(
\"
%s
\"
): "
"backsql_api_dn2odbc(
\"
%s
\"
) failed
\n
"
,
ndn
->
bv_val
,
realndn
.
bv_val
,
0
);
res
=
LDAP_OTHER
;
goto
done
;
}
}
if
(
BACKSQL_HAS_LDAPINFO_DN_RU
(
bi
)
)
{
...
...
@@ -151,8 +164,8 @@ backsql_dn2id(
* that can be searched using indexes
*/
for
(
i
=
0
,
j
=
ndn
->
bv_len
-
1
;
ndn
->
bv_val
[
i
];
i
++
,
j
--
)
{
upperdn
[
i
]
=
ndn
->
bv_val
[
j
];
for
(
i
=
0
,
j
=
real
ndn
.
bv_len
-
1
;
real
ndn
.
bv_val
[
i
];
i
++
,
j
--
)
{
upperdn
[
i
]
=
real
ndn
.
bv_val
[
j
];
}
upperdn
[
i
]
=
'\0'
;
ldap_pvt_str2upper
(
upperdn
);
...
...
@@ -163,7 +176,7 @@ backsql_dn2id(
}
else
{
if
(
BACKSQL_USE_REVERSE_DN
(
bi
)
)
{
AC_MEMCPY
(
upperdn
,
ndn
->
bv_val
,
ndn
->
bv_len
+
1
);
AC_MEMCPY
(
upperdn
,
real
ndn
.
bv_val
,
real
ndn
.
bv_len
+
1
);
ldap_pvt_str2upper
(
upperdn
);
Debug
(
LDAP_DEBUG_TRACE
,
"==>backsql_dn2id(): upperdn=
\"
%s
\"\n
"
,
...
...
@@ -171,7 +184,7 @@ backsql_dn2id(
ber_str2bv
(
upperdn
,
0
,
0
,
&
tbbDN
);
}
else
{
tbbDN
=
*
ndn
;
tbbDN
=
real
ndn
;
}
}
...
...
@@ -182,8 +195,8 @@ backsql_dn2id(
"error binding dn=
\"
%s
\"
parameter:
\n
"
,
tbbDN
.
bv_val
,
0
,
0
);
backsql_PrintErrors
(
bi
->
sql_db_env
,
dbh
,
sth
,
rc
);
SQLFreeStmt
(
sth
,
SQL_DROP
)
;
return
LDAP_OTHER
;
res
=
LDAP_OTHER
;
goto
done
;
}
rc
=
SQLExecute
(
sth
);
...
...
@@ -192,8 +205,8 @@ backsql_dn2id(
"error executing query (
\"
%s
\"
,
\"
%s
\"
):
\n
"
,
bi
->
sql_id_query
,
tbbDN
.
bv_val
,
0
);
backsql_PrintErrors
(
bi
->
sql_db_env
,
dbh
,
sth
,
rc
);
SQLFreeStmt
(
sth
,
SQL_DROP
)
;
return
LDAP_OTHER
;
res
=
LDAP_OTHER
;
goto
done
;
}
backsql_BindRowAsStrings
(
sth
,
&
row
);
...
...
@@ -234,7 +247,7 @@ backsql_dn2id(
Debug
(
LDAP_DEBUG_TRACE
,
"<==backsql_dn2id(
\"
%s
\"
): "
"dnPrettyNormal failed (%d: %s)
\n
"
,
ndn
->
bv_val
,
res
,
real
ndn
.
bv_val
,
res
,
ldap_err2string
(
res
)
);
/* cleanup... */
...
...
@@ -256,7 +269,15 @@ backsql_dn2id(
}
backsql_FreeRow
(
&
row
);
SQLFreeStmt
(
sth
,
SQL_DROP
);
done:
;
if
(
sth
!=
SQL_NULL_HSTMT
)
{
SQLFreeStmt
(
sth
,
SQL_DROP
);
}
if
(
!
BER_BVISNULL
(
&
realndn
)
&&
realndn
.
bv_val
!=
ndn
->
bv_val
)
{
ch_free
(
realndn
.
bv_val
);
}
return
res
;
}
...
...
servers/slapd/back-sql/modify.c
View file @
0cc024a3
...
...
@@ -55,19 +55,16 @@ backsql_modify( Operation *op, SlapReply *rs )
*/
rs
->
sr_text
=
(
rs
->
sr_err
==
LDAP_OTHER
)
?
"SQL-backend error"
:
NULL
;
send_ldap_result
(
op
,
rs
);
return
1
;
goto
done
;
}
/* FIXME: API... */
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modify(): "
"could not lookup entry id
\n
"
,
0
,
0
,
0
);
rs
->
sr_text
=
(
rs
->
sr_err
==
LDAP_OTHER
)
?
"SQL-backend error"
:
NULL
;
send_ldap_result
(
op
,
rs
);
return
1
;
goto
done
;
}
#ifdef BACKSQL_ARBITRARY_KEY
...
...
@@ -95,8 +92,7 @@ backsql_modify( Operation *op, SlapReply *rs )
*/
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
send_ldap_result
(
op
,
rs
);
return
1
;
goto
done
;
}
e
.
e_attrs
=
NULL
;
...
...
@@ -117,9 +113,11 @@ backsql_modify( Operation *op, SlapReply *rs )
SQLTransact
(
SQL_NULL_HENV
,
dbh
,
op
->
o_noop
?
SQL_ROLLBACK
:
SQL_COMMIT
);
}
done:
;
send_ldap_result
(
op
,
rs
);
Debug
(
LDAP_DEBUG_TRACE
,
"<==backsql_modify()
\n
"
,
0
,
0
,
0
);
return
op
->
o_noop
;
return
rs
->
sr_err
!=
LDAP_SUCCESS
?
rs
->
sr_err
:
op
->
o_noop
;
}
servers/slapd/back-sql/modrdn.c
View file @
0cc024a3
...
...
@@ -40,7 +40,8 @@ backsql_modrdn( Operation *op, SlapReply *rs )
backsql_oc_map_rec
*
oc
=
NULL
;
struct
berval
p_dn
=
BER_BVNULL
,
p_ndn
=
BER_BVNULL
,
*
new_pdn
=
NULL
,
*
new_npdn
=
NULL
,
new_dn
=
BER_BVNULL
,
new_ndn
=
BER_BVNULL
;
new_dn
=
BER_BVNULL
,
new_ndn
=
BER_BVNULL
,
realnew_dn
=
BER_BVNULL
;
LDAPRDN
new_rdn
=
NULL
;
LDAPRDN
old_rdn
=
NULL
;
Entry
e
;
...
...
@@ -63,8 +64,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
return
1
;
}
/* FIXME: API... */
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
e_id
,
dbh
,
&
op
->
o_req_ndn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modrdn(): "
"could not lookup entry id (%d)
\n
"
,
...
...
@@ -190,8 +190,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modrdn(): new entry dn is
\"
%s
\"\n
"
,
new_dn
.
bv_val
,
0
,
0
);
/* FIXME: API... */
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
pe_id
,
dbh
,
&
p_ndn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
pe_id
,
dbh
,
&
p_ndn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modrdn(): "
"could not lookup old parent entry id
\n
"
,
0
,
0
,
0
);
...
...
@@ -211,8 +210,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
(
void
)
backsql_free_entryID
(
&
pe_id
,
0
);
/* FIXME: API... */
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
new_pe_id
,
dbh
,
new_npdn
);
rs
->
sr_err
=
backsql_dn2id
(
op
,
rs
,
&
new_pe_id
,
dbh
,
new_npdn
,
1
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modrdn(): "
"could not lookup new parent entry id
\n
"
,
0
,
0
,
0
);
...
...
@@ -294,7 +292,19 @@ backsql_modrdn( Operation *op, SlapReply *rs )
goto
done
;
}
rc
=
backsql_BindParamBerVal
(
sth
,
1
,
SQL_PARAM_INPUT
,
&
new_dn
);
realnew_dn
=
new_dn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realnew_dn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_modrdn(
\"
%s
\"
): "
"backsql_api_dn2odbc(
\"
%s
\"
) failed
\n
"
,
op
->
o_req_dn
.
bv_val
,
realnew_dn
.
bv_val
,
0
);
SQLFreeStmt
(
sth
,
SQL_DROP
);
rs
->
sr_text
=
"SQL-backend error"
;
rs
->
sr_err
=
LDAP_OTHER
;
goto
done
;
}
rc
=
backsql_BindParamBerVal
(
sth
,
1
,
SQL_PARAM_INPUT
,
&
realnew_dn
);
if
(
rc
!=
SQL_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
" backsql_add_attr(): "
...
...
@@ -428,6 +438,10 @@ done:;
}
modrdn_return:
;
if
(
!
BER_BVISNULL
(
&
realnew_dn
)
&&
realnew_dn
.
bv_val
!=
new_dn
.
bv_val
)
{
ch_free
(
realnew_dn
.
bv_val
);
}
if
(
!
BER_BVISNULL
(
&
new_dn
)
)
{
slap_sl_free
(
new_dn
.
bv_val
,
op
->
o_tmpmemctx
);
}
...
...
servers/slapd/back-sql/operational.c
View file @
0cc024a3
...
...
@@ -178,19 +178,12 @@ backsql_operational(
&&
!
got
[
BACKSQL_OP_ENTRYUUID
]
&&
attr_find
(
rs
->
sr_entry
->
e_attrs
,
slap_schema
.
si_ad_entryUUID
)
==
NULL
)
{
struct
berval
ndn
;
backsql_srch_info
bsi
;
ndn
=
rs
->
sr_entry
->
e_nname
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
ndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_operational(): "
"backsql_api_dn2odbc failed
\n
"
,
0
,
0
,
0
);
return
1
;
}
rc
=
backsql_init_search
(
&
bsi
,
&
ndn
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
NULL
,
1
);
rc
=
backsql_init_search
(
&
bsi
,
&
rs
->
sr_entry
->
e_nname
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
NULL
,
(
BACKSQL_ISF_GET_ID
|
BACKSQL_ISF_MUCK
)
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_operational(): "
"could not retrieve entry ID - no such entry
\n
"
,
...
...
@@ -202,10 +195,6 @@ backsql_operational(
(
void
)
backsql_free_entryID
(
&
bsi
.
bsi_base_id
,
0
);
if
(
ndn
.
bv_val
!=
rs
->
sr_entry
->
e_nname
.
bv_val
)
{
free
(
ndn
.
bv_val
);
}
if
(
*
ap
==
NULL
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_operational(): "
"could not retrieve entryUUID
\n
"
,
...
...
servers/slapd/back-sql/proto-sql.h
View file @
0cc024a3
...
...
@@ -111,7 +111,7 @@ extern struct berval backsql_baseObject_bv;
/* stores in *id the ID in table ldap_entries corresponding to DN, if any */
int
backsql_dn2id
(
Operation
*
op
,
SlapReply
*
rs
,
backsql_entryID
*
id
,
SQLHDBC
dbh
,
struct
berval
*
dn
);
SQLHDBC
dbh
,
struct
berval
*
dn
,
int
muck
);
/* stores in *nchildren the count of children for an entry */
int
backsql_count_children
(
backsql_info
*
bi
,
SQLHDBC
dbh
,
...
...
@@ -160,11 +160,13 @@ int backsql_destroy_schema_map( backsql_info *si );
* search.c
*/
#define BACKSQL_ISF_GET_ID 0x1U
#define BACKSQL_ISF_MUCK 0x2U
int
backsql_init_search
(
backsql_srch_info
*
bsi
,
struct
berval
*
nbase
,
int
scope
,
int
slimit
,
int
tlimit
,
time_t
stoptime
,
Filter
*
filter
,
SQLHDBC
dbh
,
Operation
*
op
,
SlapReply
*
rs
,
AttributeName
*
attrs
,
int
get_base_id
);
unsigned
flags
);
/*
* sql-wrap.h
...
...
servers/slapd/back-sql/search.c
View file @
0cc024a3
...
...
@@ -113,7 +113,7 @@ backsql_init_search(
Operation
*
op
,
SlapReply
*
rs
,
AttributeName
*
attrs
,
int
get_base_id
)
unsigned
flags
)
{
AttributeName
*
p
;
int
rc
=
LDAP_SUCCESS
;
...
...
@@ -191,10 +191,11 @@ backsql_init_search(
bsi
->
bsi_flt_where
.
bb_len
=
0
;
bsi
->
bsi_filter_oc
=
NULL
;
if
(
get_base_id
)
{
if
(
flags
&
BACKSQL_ISF_GET_ID
)
{
assert
(
op
->
o_bd
->
be_private
);
rc
=
backsql_dn2id
(
op
,
rs
,
&
bsi
->
bsi_base_id
,
dbh
,
nbase
);
rc
=
backsql_dn2id
(
op
,
rs
,
&
bsi
->
bsi_base_id
,
dbh
,
nbase
,
(
flags
&
BACKSQL_ISF_MUCK
)
);
}
return
(
bsi
->
bsi_status
=
rc
);
...
...
@@ -1601,7 +1602,8 @@ backsql_search( Operation *op, SlapReply *rs )
time_t
stoptime
=
0
;
backsql_srch_info
bsi
;
backsql_entryID
*
eid
=
NULL
;
struct
berval
nbase
=
BER_BVNULL
;
struct
berval
nbase
=
BER_BVNULL
,
realndn
=
BER_BVNULL
;
manageDSAit
=
get_manageDSAit
(
op
);
...
...
@@ -1644,11 +1646,11 @@ backsql_search( Operation *op, SlapReply *rs )
/* compute it anyway; root does not use it */
stoptime
=
op
->
o_time
+
op
->
ors_tlimit
;
nbase
=
op
->
o_req_ndn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
nbase
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"backsql_search(): "
"backsql_api_dn2odbc failed
\n
"
,
0
,
0
,
0
);
realndn
=
op
->
o_req_ndn
;
if
(
backsql_api_dn2odbc
(
op
,
rs
,
&
realndn
)
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"
backsql_search(
\"
%s
\"
): "
"backsql_api_dn2odbc
(
\"
%s
\"
)
failed
\n
"
,
op
->
o_req_ndn
.
bv_val
,
realndn
.
bv_val
,
0
);
rs
->
sr_err
=
LDAP_OTHER
;
rs
->
sr_text
=
"SQL-backend error"
;
send_ldap_result
(
op
,
rs
);
...
...
@@ -1656,11 +1658,12 @@ backsql_search( Operation *op, SlapReply *rs )
}
/* init search */
rs
->
sr_err
=
backsql_init_search
(
&
bsi
,
&
nbase
,
rs
->
sr_err
=
backsql_init_search
(
&
bsi
,
&
realndn
,
op
->
ors_scope
,
op
->
ors_slimit
,
op
->
ors_tlimit
,
stoptime
,
op
->
ors_filter
,
dbh
,
op
,
rs
,
op
->
ors_attrs
,
1
);
dbh
,
op
,
rs
,
op
->
ors_attrs
,
(
BACKSQL_ISF_GET_ID
|
BACKSQL_ISF_MUCK
)
);
if
(
rs
->
sr_err
!=
LDAP_SUCCESS
)
{
send_ldap_result
(
op
,
rs
);
goto
done
;
...
...
@@ -1829,7 +1832,8 @@ backsql_search( Operation *op, SlapReply *rs )
&
e
->
e_nname
,
LDAP_SCOPE_BASE
,
-
1
,
-
1
,
-
1
,
NULL
,
dbh
,
op
,
rs
,
NULL
,
0
);
dbh
,
op
,
rs
,
NULL
,
BACKSQL_ISF_MUCK
);
bsi2
.
bsi_e
=
&
user_entry2
;
rc
=
backsql_id2entry
(
&
bsi2
,
eid
);
if
(
rc
==
LDAP_SUCCESS
)
{
...
...
@@ -2010,6 +2014,10 @@ end_of_search:;
#endif
/* BACKSQL_SYNCPROV */
done:
;
if
(
!
BER_BVISNULL
(
&
realndn
)
&&
realndn
.
bv_val
!=
op
->
o_req_ndn
.
bv_val
)
{
ch_free
(
realndn
.
bv_val
);
}
if
(
!
BER_BVISNULL
(
&
bsi
.
bsi_base_id
.
eid_ndn
)
)
{
(
void
)
backsql_free_entryID
(
&
bsi
.
bsi_base_id
,
0
);
}
...
...
@@ -2066,7 +2074,8 @@ backsql_entry_get(
ndn
,
LDAP_SCOPE_BASE
,
SLAP_NO_LIMIT
,
SLAP_NO_LIMIT
,
-
1
,
NULL
,
dbh
,
op
,
&
rs
,
at
?
anlist
:
NULL
,
1
);
dbh
,
op
,
&
rs
,
at
?
anlist
:
NULL
,
(
BACKSQL_ISF_GET_ID
|
BACKSQL_ISF_MUCK
)
);
if
(
rc
!=
LDAP_SUCCESS
)
{
return
rc
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment