s3: Remove header==NULL code from db_ctdb_marshall_record
[kai/samba.git] / source3 / include / ads.h
index 9761d54086652f953260cd5298fbaa71d4bd4195..3de1d8b199ef6fd669233605eed4c78b70ffbbef 100644 (file)
@@ -6,31 +6,8 @@
   basically this is a wrapper around ldap
 */
 
-#include "../libds/common/flags.h"
-
-enum wb_posix_mapping {
-       WB_POSIX_MAP_UNKNOWN    = -1,
-       WB_POSIX_MAP_TEMPLATE   = 0, 
-       WB_POSIX_MAP_SFU        = 1, 
-       WB_POSIX_MAP_SFU20      = 2, 
-       WB_POSIX_MAP_RFC2307    = 3,
-       WB_POSIX_MAP_UNIXINFO   = 4
-};
-
-/* there are 5 possible types of errors the ads subsystem can produce */
-enum ads_error_type {ENUM_ADS_ERROR_KRB5, ENUM_ADS_ERROR_GSS, 
-                    ENUM_ADS_ERROR_LDAP, ENUM_ADS_ERROR_SYSTEM, ENUM_ADS_ERROR_NT};
-
-typedef struct {
-       enum ads_error_type error_type;
-       union err_state{                
-               int rc;
-               NTSTATUS nt_status;
-       } err;
-       /* For error_type = ENUM_ADS_ERROR_GSS minor_status describe GSS API error */
-       /* Where rc represents major_status of GSS API error */
-       int minor_status;
-} ADS_STATUS;
+#include "libads/ads_status.h"
+#include "smb_ldap.h"
 
 struct ads_struct;
 
@@ -49,7 +26,7 @@ enum ads_saslwrap_type {
 
 typedef struct ads_struct {
        int is_mine;    /* do I own this structure's memory? */
-       
+
        /* info needed to find the server */
        struct {
                char *realm;
@@ -68,6 +45,7 @@ typedef struct ads_struct {
                char *kdc_server;
                unsigned flags;
                int time_offset;
+               char *ccache_name;
                time_t tgt_expire;
                time_t tgs_expire;
                time_t renewable;
@@ -84,6 +62,7 @@ typedef struct ads_struct {
                time_t current_time;
                char *schema_path;
                char *config_path;
+               int ldap_page_size;
        } config;
 
        /* info about the current LDAP connection */
@@ -91,7 +70,7 @@ typedef struct ads_struct {
        struct {
                LDAP *ld;
                struct sockaddr_storage ss; /* the ip of the active connection, if any */
-               time_t last_attempt; /* last attempt to reconnect */
+               time_t last_attempt; /* last attempt to reconnect, monotonic clock */
                int port;
 
                enum ads_saslwrap_type wrap_type;
@@ -125,44 +104,12 @@ typedef struct ads_struct {
 #endif /* HAVE_LDAP */
 } ADS_STRUCT;
 
-/* used to remember the names of the posix attributes in AD */
-/* see the rfc2307 & sfu nss backends */
-
-struct posix_schema {
-       char *posix_homedir_attr;
-       char *posix_shell_attr;
-       char *posix_uidnumber_attr;
-       char *posix_gidnumber_attr;
-       char *posix_gecos_attr;
-       char *posix_uid_attr;
-};
-
-
-
 #ifdef HAVE_ADS
 typedef LDAPMod **ADS_MODLIST;
 #else
 typedef void **ADS_MODLIST;
 #endif
 
-/* macros to simplify error returning */
-#define ADS_ERROR(rc) ADS_ERROR_LDAP(rc)
-#define ADS_ERROR_LDAP(rc) ads_build_error(ENUM_ADS_ERROR_LDAP, rc, 0)
-#define ADS_ERROR_SYSTEM(rc) ads_build_error(ENUM_ADS_ERROR_SYSTEM, rc?rc:EINVAL, 0)
-#define ADS_ERROR_KRB5(rc) ads_build_error(ENUM_ADS_ERROR_KRB5, rc, 0)
-#define ADS_ERROR_GSS(rc, minor) ads_build_error(ENUM_ADS_ERROR_GSS, rc, minor)
-#define ADS_ERROR_NT(rc) ads_build_nt_error(ENUM_ADS_ERROR_NT,rc)
-
-#define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
-#define ADS_SUCCESS ADS_ERROR(0)
-
-#define ADS_ERROR_HAVE_NO_MEMORY(x) do { \
-        if (!(x)) {\
-                return ADS_ERROR(LDAP_NO_MEMORY);\
-        }\
-} while (0)
-
-
 /* time between reconnect attempts */
 #define ADS_RECONNECT_TIME 5
 
@@ -175,109 +122,11 @@ typedef void **ADS_MODLIST;
 #define ADS_EXTENDED_DN_OID    "1.2.840.113556.1.4.529"
 #define ADS_SD_FLAGS_OID       "1.2.840.113556.1.4.801"
 
-/* ldap attribute oids (Services for Unix 3.0, 3.5) */
-#define ADS_ATTR_SFU_UIDNUMBER_OID     "1.2.840.113556.1.6.18.1.310"
-#define ADS_ATTR_SFU_GIDNUMBER_OID     "1.2.840.113556.1.6.18.1.311"
-#define ADS_ATTR_SFU_HOMEDIR_OID       "1.2.840.113556.1.6.18.1.344"
-#define ADS_ATTR_SFU_SHELL_OID                 "1.2.840.113556.1.6.18.1.312"
-#define ADS_ATTR_SFU_GECOS_OID                 "1.2.840.113556.1.6.18.1.337"
-#define ADS_ATTR_SFU_UID_OID            "1.2.840.113556.1.6.18.1.309"
-
-/* ldap attribute oids (Services for Unix 2.0) */
-#define ADS_ATTR_SFU20_UIDNUMBER_OID   "1.2.840.113556.1.4.7000.187.70"
-#define ADS_ATTR_SFU20_GIDNUMBER_OID   "1.2.840.113556.1.4.7000.187.71"
-#define ADS_ATTR_SFU20_HOMEDIR_OID     "1.2.840.113556.1.4.7000.187.106"
-#define ADS_ATTR_SFU20_SHELL_OID       "1.2.840.113556.1.4.7000.187.72"
-#define ADS_ATTR_SFU20_GECOS_OID       "1.2.840.113556.1.4.7000.187.97"
-#define ADS_ATTR_SFU20_UID_OID          "1.2.840.113556.1.4.7000.187.102"
-
-
-/* ldap attribute oids (RFC2307) */
-#define ADS_ATTR_RFC2307_UIDNUMBER_OID "1.3.6.1.1.1.1.0"
-#define ADS_ATTR_RFC2307_GIDNUMBER_OID "1.3.6.1.1.1.1.1"
-#define ADS_ATTR_RFC2307_HOMEDIR_OID   "1.3.6.1.1.1.1.3"
-#define ADS_ATTR_RFC2307_SHELL_OID     "1.3.6.1.1.1.1.4"
-#define ADS_ATTR_RFC2307_GECOS_OID     "1.3.6.1.1.1.1.2"
-#define ADS_ATTR_RFC2307_UID_OID        "0.9.2342.19200300.100.1.1"
-
 /* ldap bitwise searches */
 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
 #define ADS_LDAP_MATCHING_RULE_BIT_OR  "1.2.840.113556.1.4.804"
 
 #define ADS_PINGS          0x0000FFFF  /* Ping response */
-#define ADS_DNS_CONTROLLER 0x20000000  /* DomainControllerName is a DNS name*/
-#define ADS_DNS_DOMAIN     0x40000000  /* DomainName is a DNS name */
-#define ADS_DNS_FOREST     0x80000000  /* DnsForestName is a DNS name */
-
-/* ads auth control flags */
-#define ADS_AUTH_DISABLE_KERBEROS 0x0001
-#define ADS_AUTH_NO_BIND          0x0002
-#define ADS_AUTH_ANON_BIND        0x0004
-#define ADS_AUTH_SIMPLE_BIND      0x0008
-#define ADS_AUTH_ALLOW_NTLMSSP    0x0010
-#define ADS_AUTH_SASL_SIGN        0x0020
-#define ADS_AUTH_SASL_SEAL        0x0040
-#define ADS_AUTH_SASL_FORCE       0x0080
-#define ADS_AUTH_USER_CREDS       0x0100
-
-/* Kerberos environment variable names */
-#define KRB5_ENV_CCNAME "KRB5CCNAME"
-
-/* Heimdal uses a slightly different name */
-#if defined(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5)
-#define ENCTYPE_ARCFOUR_HMAC ENCTYPE_ARCFOUR_HMAC_MD5
-#endif
-
-/* The older versions of heimdal that don't have this
-   define don't seem to use it anyway.  I'm told they
-   always use a subkey */
-#ifndef HAVE_AP_OPTS_USE_SUBKEY
-#define AP_OPTS_USE_SUBKEY 0
-#endif
-
-#define WELL_KNOWN_GUID_COMPUTERS      "AA312825768811D1ADED00C04FD8D5CD" 
-#define WELL_KNOWN_GUID_USERS          "A9D1CA15768811D1ADED00C04FD8D5CD"
-
-#ifndef KRB5_ADDR_NETBIOS
-#define KRB5_ADDR_NETBIOS 0x14
-#endif
-
-#ifndef KRB5KRB_ERR_RESPONSE_TOO_BIG
-#define KRB5KRB_ERR_RESPONSE_TOO_BIG (-1765328332L)
-#endif
-
-#ifdef HAVE_KRB5
-typedef struct {
-#if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
-       krb5_address **addrs;
-#elif defined(HAVE_KRB5_ADDRESSES) /* Heimdal */
-       krb5_addresses *addrs;
-#else
-#error UNKNOWN_KRB5_ADDRESS_TYPE
-#endif /* defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) */
-} smb_krb5_addresses;
-
-#ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE /* Heimdal */
-#define KRB5_KEY_TYPE(k)       ((k)->keytype)
-#define KRB5_KEY_LENGTH(k)     ((k)->keyvalue.length)
-#define KRB5_KEY_DATA(k)       ((k)->keyvalue.data)
-#define KRB5_KEY_DATA_CAST     void
-#else /* MIT */
-#define KRB5_KEY_TYPE(k)       ((k)->enctype)
-#define KRB5_KEY_LENGTH(k)     ((k)->length)
-#define KRB5_KEY_DATA(k)       ((k)->contents)
-#define KRB5_KEY_DATA_CAST     krb5_octet
-#endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
-
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
-#define KRB5_KT_KEY(k)         (&(k)->key)
-#elif HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK          /* Heimdal */
-#define KRB5_KT_KEY(k)         (&(k)->keyblock)
-#else
-#error krb5_keytab_entry has no key or keyblock member
-#endif /* HAVE_KRB5_KEYTAB_ENTRY_KEY */
-
-#endif /* HAVE_KRB5 */
 
 enum ads_extended_dn_flags {
        ADS_EXTENDED_DN_HEX_STRING      = 0,
@@ -293,6 +142,12 @@ typedef struct {
        int critical;
 } ads_control;
 
-#define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
+#include "libads/ads_proto.h"
+
+#ifdef HAVE_LDAP
+#include "libads/ads_ldap_protos.h"
+#endif
+
+#include "libads/kerberos_proto.h"
 
 #endif /* _INCLUDE_ADS_H_ */