bool tevent_req_ldap_error(struct tevent_req *req, TLDAPRC rc);
bool tevent_req_is_ldap_error(struct tevent_req *req, TLDAPRC *perr);
+struct tstream_context;
+struct tldap_context *tldap_context_create_from_plain_stream(
+ TALLOC_CTX *mem_ctx, struct tstream_context **stream);
struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd);
struct tstream_context *tldap_get_plain_tstream(struct tldap_context *ld);
bool tldap_has_tls_tstream(struct tldap_context *ld);
return result;
}
-struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd)
+struct tldap_context *tldap_context_create_from_plain_stream(
+ TALLOC_CTX *mem_ctx, struct tstream_context **stream)
{
struct tldap_context *ctx;
- int ret;
ctx = talloc_zero(mem_ctx, struct tldap_context);
if (ctx == NULL) {
return NULL;
}
- ret = tstream_bsd_existing_socket(ctx, fd, &ctx->plain);
- if (ret == -1) {
- TALLOC_FREE(ctx);
- return NULL;
- }
+ ctx->plain = talloc_move(ctx, stream);
ctx->active = ctx->plain;
ctx->msgid = 1;
ctx->ld_version = 3;
return ctx;
}
+struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd)
+{
+ struct tldap_context *ctx = NULL;
+ struct tstream_context *stream = NULL;
+ int ret;
+
+ ret = tstream_bsd_existing_socket(mem_ctx, fd, &stream);
+ if (ret == -1) {
+ return NULL;
+ }
+
+ ctx = tldap_context_create_from_plain_stream(mem_ctx, &stream);
+ if (ctx == NULL) {
+ TALLOC_FREE(stream);
+ return NULL;
+ }
+ return ctx;
+}
+
bool tldap_connection_ok(struct tldap_context *ld)
{
int ret;