[745] | 1 | #ifndef _INCLUDE_ADS_H_
|
---|
| 2 | #define _INCLUDE_ADS_H_
|
---|
| 3 | /*
|
---|
| 4 | header for ads (active directory) library routines
|
---|
| 5 |
|
---|
| 6 | basically this is a wrapper around ldap
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | #include "libads/ads_status.h"
|
---|
| 10 | #include "smb_ldap.h"
|
---|
| 11 |
|
---|
| 12 | struct ads_struct;
|
---|
| 13 |
|
---|
| 14 | struct ads_saslwrap_ops {
|
---|
| 15 | const char *name;
|
---|
| 16 | ADS_STATUS (*wrap)(struct ads_struct *, uint8 *buf, uint32 len);
|
---|
| 17 | ADS_STATUS (*unwrap)(struct ads_struct *);
|
---|
| 18 | void (*disconnect)(struct ads_struct *);
|
---|
| 19 | };
|
---|
| 20 |
|
---|
| 21 | enum ads_saslwrap_type {
|
---|
| 22 | ADS_SASLWRAP_TYPE_PLAIN = 1,
|
---|
| 23 | ADS_SASLWRAP_TYPE_SIGN = 2,
|
---|
| 24 | ADS_SASLWRAP_TYPE_SEAL = 4
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | typedef struct ads_struct {
|
---|
| 28 | int is_mine; /* do I own this structure's memory? */
|
---|
| 29 |
|
---|
| 30 | /* info needed to find the server */
|
---|
| 31 | struct {
|
---|
| 32 | char *realm;
|
---|
| 33 | char *workgroup;
|
---|
| 34 | char *ldap_server;
|
---|
| 35 | int foreign; /* set to 1 if connecting to a foreign
|
---|
| 36 | * realm */
|
---|
| 37 | bool gc; /* Is this a global catalog server? */
|
---|
| 38 | } server;
|
---|
| 39 |
|
---|
| 40 | /* info needed to authenticate */
|
---|
| 41 | struct {
|
---|
| 42 | char *realm;
|
---|
| 43 | char *password;
|
---|
| 44 | char *user_name;
|
---|
| 45 | char *kdc_server;
|
---|
| 46 | unsigned flags;
|
---|
| 47 | int time_offset;
|
---|
| 48 | time_t tgt_expire;
|
---|
| 49 | time_t tgs_expire;
|
---|
| 50 | time_t renewable;
|
---|
| 51 | } auth;
|
---|
| 52 |
|
---|
| 53 | /* info derived from the servers config */
|
---|
| 54 | struct {
|
---|
| 55 | uint32 flags; /* cldap flags identifying the services. */
|
---|
| 56 | char *realm;
|
---|
| 57 | char *bind_path;
|
---|
| 58 | char *ldap_server_name;
|
---|
| 59 | char *server_site_name;
|
---|
| 60 | char *client_site_name;
|
---|
| 61 | time_t current_time;
|
---|
| 62 | char *schema_path;
|
---|
| 63 | char *config_path;
|
---|
[751] | 64 | int ldap_page_size;
|
---|
[745] | 65 | } config;
|
---|
| 66 |
|
---|
| 67 | /* info about the current LDAP connection */
|
---|
| 68 | #ifdef HAVE_LDAP
|
---|
| 69 | struct {
|
---|
| 70 | LDAP *ld;
|
---|
| 71 | struct sockaddr_storage ss; /* the ip of the active connection, if any */
|
---|
| 72 | time_t last_attempt; /* last attempt to reconnect, monotonic clock */
|
---|
| 73 | int port;
|
---|
| 74 |
|
---|
| 75 | enum ads_saslwrap_type wrap_type;
|
---|
| 76 |
|
---|
| 77 | #ifdef HAVE_LDAP_SASL_WRAPPING
|
---|
| 78 | Sockbuf_IO_Desc *sbiod; /* lowlevel state for LDAP wrapping */
|
---|
| 79 | #endif /* HAVE_LDAP_SASL_WRAPPING */
|
---|
| 80 | TALLOC_CTX *mem_ctx;
|
---|
| 81 | const struct ads_saslwrap_ops *wrap_ops;
|
---|
| 82 | void *wrap_private_data;
|
---|
| 83 | struct {
|
---|
| 84 | uint32 ofs;
|
---|
| 85 | uint32 needed;
|
---|
| 86 | uint32 left;
|
---|
| 87 | #define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF
|
---|
| 88 | uint32 max_wrapped;
|
---|
| 89 | uint32 min_wrapped;
|
---|
| 90 | uint32 size;
|
---|
| 91 | uint8 *buf;
|
---|
| 92 | } in;
|
---|
| 93 | struct {
|
---|
| 94 | uint32 ofs;
|
---|
| 95 | uint32 left;
|
---|
| 96 | #define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000
|
---|
| 97 | uint32 max_unwrapped;
|
---|
| 98 | uint32 sig_size;
|
---|
| 99 | uint32 size;
|
---|
| 100 | uint8 *buf;
|
---|
| 101 | } out;
|
---|
| 102 | } ldap;
|
---|
| 103 | #endif /* HAVE_LDAP */
|
---|
| 104 | } ADS_STRUCT;
|
---|
| 105 |
|
---|
| 106 | #ifdef HAVE_ADS
|
---|
| 107 | typedef LDAPMod **ADS_MODLIST;
|
---|
| 108 | #else
|
---|
| 109 | typedef void **ADS_MODLIST;
|
---|
| 110 | #endif
|
---|
| 111 |
|
---|
| 112 | /* time between reconnect attempts */
|
---|
| 113 | #define ADS_RECONNECT_TIME 5
|
---|
| 114 |
|
---|
| 115 | /* ldap control oids */
|
---|
| 116 | #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
|
---|
| 117 | #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
|
---|
| 118 | #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
|
---|
| 119 | #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
|
---|
| 120 | #define ADS_ASQ_OID "1.2.840.113556.1.4.1504"
|
---|
| 121 | #define ADS_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
|
---|
| 122 | #define ADS_SD_FLAGS_OID "1.2.840.113556.1.4.801"
|
---|
| 123 |
|
---|
| 124 | /* ldap bitwise searches */
|
---|
| 125 | #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
|
---|
| 126 | #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
|
---|
| 127 |
|
---|
| 128 | #define ADS_PINGS 0x0000FFFF /* Ping response */
|
---|
| 129 |
|
---|
| 130 | /* ads auth control flags */
|
---|
| 131 | #define ADS_AUTH_DISABLE_KERBEROS 0x0001
|
---|
| 132 | #define ADS_AUTH_NO_BIND 0x0002
|
---|
| 133 | #define ADS_AUTH_ANON_BIND 0x0004
|
---|
| 134 | #define ADS_AUTH_SIMPLE_BIND 0x0008
|
---|
| 135 | #define ADS_AUTH_ALLOW_NTLMSSP 0x0010
|
---|
| 136 | #define ADS_AUTH_SASL_SIGN 0x0020
|
---|
| 137 | #define ADS_AUTH_SASL_SEAL 0x0040
|
---|
| 138 | #define ADS_AUTH_SASL_FORCE 0x0080
|
---|
| 139 | #define ADS_AUTH_USER_CREDS 0x0100
|
---|
| 140 |
|
---|
| 141 | enum ads_extended_dn_flags {
|
---|
| 142 | ADS_EXTENDED_DN_HEX_STRING = 0,
|
---|
| 143 | ADS_EXTENDED_DN_STRING = 1 /* not supported on win2k */
|
---|
| 144 | };
|
---|
| 145 |
|
---|
| 146 | /* this is probably not very well suited to pass other controls generically but
|
---|
| 147 | * is good enough for the extended dn control where it is only used for atm */
|
---|
| 148 |
|
---|
| 149 | typedef struct {
|
---|
| 150 | const char *control;
|
---|
| 151 | int val;
|
---|
| 152 | int critical;
|
---|
| 153 | } ads_control;
|
---|
| 154 |
|
---|
| 155 | #include "libads/ads_proto.h"
|
---|
| 156 |
|
---|
| 157 | #ifdef HAVE_LDAP
|
---|
| 158 | #include "libads/ads_ldap_protos.h"
|
---|
| 159 | #endif
|
---|
| 160 |
|
---|
| 161 | #include "libads/kerberos_proto.h"
|
---|
| 162 |
|
---|
| 163 | #endif /* _INCLUDE_ADS_H_ */
|
---|