Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / libcli / ldap / ldap.h
index 96c1b82ca3cef17333ba2b44b3409d625619361d..abb4617c485b43d91fa42c1903f08c4c2940607d 100644 (file)
@@ -5,7 +5,7 @@
     
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
 */
 
-#ifndef _SMB_LDAP_H
-#define _SMB_LDAP_H
+#ifndef _SMB_LDAP_H_
+#define _SMB_LDAP_H_
+
+#include "libcli/ldap/ldap_errors.h"
+#include "lib/ldb/include/ldb.h"
+#include "librpc/gen_ndr/misc.h"
 
 enum ldap_request_tag {
        LDAP_TAG_BindRequest = 0,
@@ -57,12 +60,6 @@ struct ldap_Result {
        const char *referral;
 };
 
-struct ldap_attribute {
-       const char *name;
-       int num_values;
-       DATA_BLOB *values;
-};
-
 struct ldap_BindRequest {
        int version;
        const char *dn;
@@ -71,7 +68,7 @@ struct ldap_BindRequest {
                const char *password;
                struct {
                        const char *mechanism;
-                       DATA_BLOB creds;
+                       DATA_BLOB *secblob;/* optional */
                } SASL;
        } creds;
 };
@@ -79,11 +76,12 @@ struct ldap_BindRequest {
 struct ldap_BindResponse {
        struct ldap_Result response;
        union {
-               DATA_BLOB credentials;
-       } SASL_Credentials;
+               DATA_BLOB *secblob;/* optional */
+       } SASL;
 };
 
 struct ldap_UnbindRequest {
+       uint8_t __dummy;
 };
 
 enum ldap_scope {
@@ -103,10 +101,10 @@ struct ldap_SearchRequest {
        const char *basedn;
        enum ldap_scope scope;
        enum ldap_deref deref;
-       uint32 timelimit;
-       uint32 sizelimit;
-       BOOL attributesonly;
-       char *filter;
+       uint32_t timelimit;
+       uint32_t sizelimit;
+       bool attributesonly;
+       struct ldb_parse_tree *tree;
        int num_attributes;
        const char **attributes;
 };
@@ -114,12 +112,11 @@ struct ldap_SearchRequest {
 struct ldap_SearchResEntry {
        const char *dn;
        int num_attributes;
-       struct ldap_attribute *attributes;
+       struct ldb_message_element *attributes;
 };
 
 struct ldap_SearchResRef {
-       int num_referrals;
-       const char **referrals;
+       const char *referral;
 };
 
 enum ldap_modify_type {
@@ -131,7 +128,7 @@ enum ldap_modify_type {
 
 struct ldap_mod {
        enum ldap_modify_type type;
-       struct ldap_attribute attrib;
+       struct ldb_message_element attrib;
 };
 
 struct ldap_ModifyRequest {
@@ -143,7 +140,7 @@ struct ldap_ModifyRequest {
 struct ldap_AddRequest {
        const char *dn;
        int num_attributes;
-       struct ldap_attribute *attributes;
+       struct ldb_message_element *attributes;
 };
 
 struct ldap_DelRequest {
@@ -153,32 +150,33 @@ struct ldap_DelRequest {
 struct ldap_ModifyDNRequest {
        const char *dn;
        const char *newrdn;
-       BOOL deleteolddn;
-       const char *newsuperior;
+       bool deleteolddn;
+       const char *newsuperior;/* optional */
 };
 
 struct ldap_CompareRequest {
        const char *dn;
        const char *attribute;
-       const char *value;
+       DATA_BLOB value;
 };
 
 struct ldap_AbandonRequest {
-       uint32 messageid;
+       uint32_t messageid;
 };
 
 struct ldap_ExtendedRequest {
        const char *oid;
-       DATA_BLOB value;
+       DATA_BLOB *value;/* optional */
 };
 
 struct ldap_ExtendedResponse {
        struct ldap_Result response;
-       const char *name;
-       DATA_BLOB value;
+       const char *oid;/* optional */
+       DATA_BLOB *value;/* optional */
 };
 
 union ldap_Request {
+       struct ldap_Result              GeneralResult;
        struct ldap_BindRequest         BindRequest;
        struct ldap_BindResponse        BindResponse;
        struct ldap_UnbindRequest       UnbindRequest;
@@ -201,46 +199,22 @@ union ldap_Request {
        struct ldap_ExtendedResponse    ExtendedResponse;
 };
 
-struct ldap_Control {
-       const char *oid;
-       BOOL        critical;
-       DATA_BLOB   value;
-};
 
 struct ldap_message {
-       TALLOC_CTX             *mem_ctx;
-       uint32                  messageid;
-       uint8                   type;
-       union  ldap_Request     r;
-       int                     num_controls;
-       struct ldap_Control    *controls;
-};
-
-struct ldap_queue_entry {
-       struct ldap_queue_entry *next, *prev;
-       int msgid;
-       struct ldap_message *msg;
+       int                     messageid;
+       enum ldap_request_tag   type;
+       union ldap_Request      r;
+       struct ldb_control    **controls;
+       bool                   *controls_decoded;
 };
 
-struct ldap_connection {
-       TALLOC_CTX *mem_ctx;
-       int sock;
-       int next_msgid;
-       char *host;
-       uint16 port;
-       BOOL ldaps;
-
-       const char *auth_dn;
-       const char *simple_pw;
+struct tevent_context;
+struct cli_credentials;
+struct dom_sid;
+struct asn1_data;
 
-       /* Current outstanding search entry */
-       int searchid;
-
-       /* List for incoming search entries */
-       struct ldap_queue_entry *search_entries;
-
-       /* Outstanding LDAP requests that have not yet been replied to */
-       struct ldap_queue_entry *outstanding;
-};
+struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
+NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg);
+bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx);
 
-#endif
+#endif