smbd: Convert open_np_file to synthetic_smb_fname
[Samba/bjacke.git] / source3 / include / ads.h
blob3de1d8b199ef6fd669233605eed4c78b70ffbbef
1 #ifndef _INCLUDE_ADS_H_
2 #define _INCLUDE_ADS_H_
3 /*
4 header for ads (active directory) library routines
6 basically this is a wrapper around ldap
7 */
9 #include "libads/ads_status.h"
10 #include "smb_ldap.h"
12 struct ads_struct;
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 *);
21 enum ads_saslwrap_type {
22 ADS_SASLWRAP_TYPE_PLAIN = 1,
23 ADS_SASLWRAP_TYPE_SIGN = 2,
24 ADS_SASLWRAP_TYPE_SEAL = 4
27 typedef struct ads_struct {
28 int is_mine; /* do I own this structure's memory? */
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;
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 char *ccache_name;
49 time_t tgt_expire;
50 time_t tgs_expire;
51 time_t renewable;
52 } auth;
54 /* info derived from the servers config */
55 struct {
56 uint32 flags; /* cldap flags identifying the services. */
57 char *realm;
58 char *bind_path;
59 char *ldap_server_name;
60 char *server_site_name;
61 char *client_site_name;
62 time_t current_time;
63 char *schema_path;
64 char *config_path;
65 int ldap_page_size;
66 } config;
68 /* info about the current LDAP connection */
69 #ifdef HAVE_LDAP
70 struct {
71 LDAP *ld;
72 struct sockaddr_storage ss; /* the ip of the active connection, if any */
73 time_t last_attempt; /* last attempt to reconnect, monotonic clock */
74 int port;
76 enum ads_saslwrap_type wrap_type;
78 #ifdef HAVE_LDAP_SASL_WRAPPING
79 Sockbuf_IO_Desc *sbiod; /* lowlevel state for LDAP wrapping */
80 #endif /* HAVE_LDAP_SASL_WRAPPING */
81 TALLOC_CTX *mem_ctx;
82 const struct ads_saslwrap_ops *wrap_ops;
83 void *wrap_private_data;
84 struct {
85 uint32 ofs;
86 uint32 needed;
87 uint32 left;
88 #define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF
89 uint32 max_wrapped;
90 uint32 min_wrapped;
91 uint32 size;
92 uint8 *buf;
93 } in;
94 struct {
95 uint32 ofs;
96 uint32 left;
97 #define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000
98 uint32 max_unwrapped;
99 uint32 sig_size;
100 uint32 size;
101 uint8 *buf;
102 } out;
103 } ldap;
104 #endif /* HAVE_LDAP */
105 } ADS_STRUCT;
107 #ifdef HAVE_ADS
108 typedef LDAPMod **ADS_MODLIST;
109 #else
110 typedef void **ADS_MODLIST;
111 #endif
113 /* time between reconnect attempts */
114 #define ADS_RECONNECT_TIME 5
116 /* ldap control oids */
117 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
118 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
119 #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
120 #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
121 #define ADS_ASQ_OID "1.2.840.113556.1.4.1504"
122 #define ADS_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
123 #define ADS_SD_FLAGS_OID "1.2.840.113556.1.4.801"
125 /* ldap bitwise searches */
126 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
127 #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
129 #define ADS_PINGS 0x0000FFFF /* Ping response */
131 enum ads_extended_dn_flags {
132 ADS_EXTENDED_DN_HEX_STRING = 0,
133 ADS_EXTENDED_DN_STRING = 1 /* not supported on win2k */
136 /* this is probably not very well suited to pass other controls generically but
137 * is good enough for the extended dn control where it is only used for atm */
139 typedef struct {
140 const char *control;
141 int val;
142 int critical;
143 } ads_control;
145 #include "libads/ads_proto.h"
147 #ifdef HAVE_LDAP
148 #include "libads/ads_ldap_protos.h"
149 #endif
151 #include "libads/kerberos_proto.h"
153 #endif /* _INCLUDE_ADS_H_ */