1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Mozilla Communicator client code, released
15  * March 31, 1998.
16  *
17  * The Initial Developer of the Original Code is
18  * Netscape Communications Corporation.
19  * Portions created by the Initial Developer are Copyright (C) 1998-1999
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either of the GNU General Public License Version 2 or later (the "GPL"),
26  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
38 #ifndef _LDAPROT_H
39 #define _LDAPROT_H
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define LDAP_VERSION1	1
46 #define LDAP_VERSION2	2
47 #define LDAP_VERSION3	3
48 #define LDAP_VERSION	LDAP_VERSION3
49 
50 #define COMPAT20
51 #define COMPAT30
52 #if defined(COMPAT20) || defined(COMPAT30)
53 #define COMPAT
54 #endif
55 
56 #define LDAP_URL_PREFIX		"ldap://"
57 #define LDAP_URL_PREFIX_LEN	7
58 #define LDAPS_URL_PREFIX	"ldaps://"
59 #define LDAPS_URL_PREFIX_LEN	8
60 #define LDAP_REF_STR		"Referral:\n"
61 #define LDAP_REF_STR_LEN	10
62 
63 /*
64  * specific LDAP instantiations of BER types we know about
65  */
66 
67 /* general stuff */
68 #define LDAP_TAG_MESSAGE	0x30L	/* tag is 16 + constructed bit */
69 #define OLD_LDAP_TAG_MESSAGE	0x10L	/* forgot the constructed bit  */
70 #define LDAP_TAG_MSGID		0x02L   /* INTEGER */
71 #define LDAP_TAG_LDAPDN		0x04L	/* OCTET STRING */
72 #define LDAP_TAG_CONTROLS	0xa0L	/* context specific + constructed + 0 */
73 #define LDAP_TAG_REFERRAL	0xa3L	/* context specific + constructed + 3 */
74 #define LDAP_TAG_NEWSUPERIOR	0x80L	/* context specific + primitive + 0 */
75 #define LDAP_TAG_MRA_OID	0x81L	/* context specific + primitive + 1 */
76 #define LDAP_TAG_MRA_TYPE	0x82L	/* context specific + primitive + 2 */
77 #define LDAP_TAG_MRA_VALUE	0x83L	/* context specific + primitive + 3 */
78 #define LDAP_TAG_MRA_DNATTRS	0x84L	/* context specific + primitive + 4 */
79 #define LDAP_TAG_EXOP_REQ_OID	0x80L	/* context specific + primitive + 0 */
80 #define LDAP_TAG_EXOP_REQ_VALUE	0x81L	/* context specific + primitive + 1 */
81 #define LDAP_TAG_EXOP_RES_OID	0x8aL	/* context specific + primitive + 10 */
82 #define LDAP_TAG_EXOP_RES_VALUE	0x8bL	/* context specific + primitive + 11 */
83 #define LDAP_TAG_SK_MATCHRULE   0x80L   /* context specific + primitive + 0 */
84 #define LDAP_TAG_SK_REVERSE 	0x81L	/* context specific + primitive + 1 */
85 #define LDAP_TAG_SR_ATTRTYPE    0x80L   /* context specific + primitive + 0 */
86 #define LDAP_TAG_SASL_RES_CREDS	0x87L	/* context specific + primitive + 7 */
87 #define LDAP_TAG_VLV_BY_INDEX	0xa0L	/* context specific + constructed + 0 */
88 #define LDAP_TAG_VLV_BY_VALUE	0x81L	/* context specific + primitive + 1 */
89 #define LDAP_TAG_PWP_WARNING	0xA0L   /* context specific + constructed */
90 #define LDAP_TAG_PWP_SECSLEFT	0x80L   /* context specific + primitive */
91 #define LDAP_TAG_PWP_GRCLOGINS	0x81L   /* context specific + primitive + 1 */
92 #define LDAP_TAG_PWP_ERROR	0x81L   /* context specific + primitive + 1 */
93 #define LDAP_TAG_PWDMOD_REQ_ID  0x80L   /* context specific + primitive + 0 */
94 #define LDAP_TAG_PWDMOD_REQ_OLD 0x81L   /* context specific + primitive + 1 */
95 #define LDAP_TAG_PWDMOD_REQ_NEW 0x82L   /* context specific + primitive + 2 */
96 #define LDAP_TAG_PWDMOD_RES_GEN 0x80L   /* context specific + primitive + 0 */
97 
98 /* possible operations a client can invoke */
99 #define LDAP_REQ_BIND		0x60L	/* application + constructed + 0 */
100 #define LDAP_REQ_UNBIND		0x42L	/* application + primitive   + 2 */
101 #define LDAP_REQ_SEARCH		0x63L	/* application + constructed + 3 */
102 #define LDAP_REQ_MODIFY		0x66L	/* application + constructed + 6 */
103 #define LDAP_REQ_ADD		0x68L	/* application + constructed + 8 */
104 #define LDAP_REQ_DELETE		0x4aL	/* application + primitive   + 10 */
105 #define LDAP_REQ_MODRDN		0x6cL	/* application + constructed + 12 */
106 #define LDAP_REQ_MODDN		0x6cL	/* application + constructed + 12 */
107 #define LDAP_REQ_RENAME		0x6cL	/* application + constructed + 12 */
108 #define LDAP_REQ_COMPARE	0x6eL	/* application + constructed + 14 */
109 #define LDAP_REQ_ABANDON	0x50L	/* application + primitive   + 16 */
110 #define LDAP_REQ_EXTENDED	0x77L	/* application + constructed + 23 */
111 
112 /* U-M LDAP release 3.0 compatibility stuff */
113 #define LDAP_REQ_UNBIND_30	0x62L
114 #define LDAP_REQ_DELETE_30	0x6aL
115 #define LDAP_REQ_ABANDON_30	0x70L
116 
117 /*
118  * old broken stuff for backwards compatibility - forgot application tag
119  * and constructed/primitive bit
120  */
121 #define OLD_LDAP_REQ_BIND	0x00L
122 #define OLD_LDAP_REQ_UNBIND	0x02L
123 #define OLD_LDAP_REQ_SEARCH	0x03L
124 #define OLD_LDAP_REQ_MODIFY	0x06L
125 #define OLD_LDAP_REQ_ADD	0x08L
126 #define OLD_LDAP_REQ_DELETE	0x0aL
127 #define OLD_LDAP_REQ_MODRDN	0x0cL
128 #define OLD_LDAP_REQ_MODDN	0x0cL
129 #define OLD_LDAP_REQ_COMPARE	0x0eL
130 #define OLD_LDAP_REQ_ABANDON	0x10L
131 
132 /* old broken stuff for backwards compatibility */
133 #define OLD_LDAP_RES_BIND		0x01L
134 #define OLD_LDAP_RES_SEARCH_ENTRY	0x04L
135 #define OLD_LDAP_RES_SEARCH_RESULT	0x05L
136 #define OLD_LDAP_RES_MODIFY		0x07L
137 #define OLD_LDAP_RES_ADD		0x09L
138 #define OLD_LDAP_RES_DELETE		0x0bL
139 #define OLD_LDAP_RES_MODRDN		0x0dL
140 #define OLD_LDAP_RES_MODDN		0x0dL
141 #define OLD_LDAP_RES_COMPARE		0x0fL
142 
143 /* U-M LDAP 3.0 compatibility auth methods */
144 #define LDAP_AUTH_SIMPLE_30	0xa0L	/* context specific + constructed */
145 #define LDAP_AUTH_KRBV41_30	0xa1L	/* context specific + constructed */
146 #define LDAP_AUTH_KRBV42_30	0xa2L	/* context specific + constructed */
147 
148 /* old broken stuff */
149 #define OLD_LDAP_AUTH_SIMPLE	0x00L
150 #define OLD_LDAP_AUTH_KRBV4	0x01L
151 #define OLD_LDAP_AUTH_KRBV42	0x02L
152 
153 /* U-M LDAP 3.0 compatibility filter types */
154 #define LDAP_FILTER_PRESENT_30	0xa7L	/* context specific + constructed */
155 
156 /* filter types */
157 #define LDAP_FILTER_AND		0xa0L	/* context specific + constructed + 0 */
158 #define LDAP_FILTER_OR		0xa1L	/* context specific + constructed + 1 */
159 #define LDAP_FILTER_NOT		0xa2L	/* context specific + constructed + 2 */
160 #define LDAP_FILTER_EQUALITY	0xa3L	/* context specific + constructed + 3 */
161 #define LDAP_FILTER_SUBSTRINGS	0xa4L	/* context specific + constructed + 4 */
162 #define LDAP_FILTER_GE		0xa5L	/* context specific + constructed + 5 */
163 #define LDAP_FILTER_LE		0xa6L	/* context specific + constructed + 6 */
164 #define LDAP_FILTER_PRESENT	0x87L	/* context specific + primitive   + 7 */
165 #define LDAP_FILTER_APPROX	0xa8L	/* context specific + constructed + 8 */
166 #define LDAP_FILTER_EXTENDED	0xa9L	/* context specific + constructed + 0 */
167 
168 /* old broken stuff */
169 #define OLD_LDAP_FILTER_AND		0x00L
170 #define OLD_LDAP_FILTER_OR		0x01L
171 #define OLD_LDAP_FILTER_NOT		0x02L
172 #define OLD_LDAP_FILTER_EQUALITY	0x03L
173 #define OLD_LDAP_FILTER_SUBSTRINGS	0x04L
174 #define OLD_LDAP_FILTER_GE		0x05L
175 #define OLD_LDAP_FILTER_LE		0x06L
176 #define OLD_LDAP_FILTER_PRESENT		0x07L
177 #define OLD_LDAP_FILTER_APPROX		0x08L
178 
179 /* substring filter component types */
180 #define LDAP_SUBSTRING_INITIAL	0x80L	/* context specific + primitive + 0 */
181 #define LDAP_SUBSTRING_ANY	0x81L	/* context specific + primitive + 1 */
182 #define LDAP_SUBSTRING_FINAL	0x82L	/* context specific + primitive + 2 */
183 
184 /* extended filter component types */
185 #define LDAP_FILTER_EXTENDED_OID	0x81L	/* context spec. + prim. + 1 */
186 #define LDAP_FILTER_EXTENDED_TYPE	0x82L	/* context spec. + prim. + 2 */
187 #define LDAP_FILTER_EXTENDED_VALUE	0x83L	/* context spec. + prim. + 3 */
188 #define LDAP_FILTER_EXTENDED_DNATTRS	0x84L	/* context spec. + prim. + 4 */
189 
190 /* U-M LDAP 3.0 compatibility substring filter component types */
191 #define LDAP_SUBSTRING_INITIAL_30	0xa0L	/* context specific */
192 #define LDAP_SUBSTRING_ANY_30		0xa1L	/* context specific */
193 #define LDAP_SUBSTRING_FINAL_30		0xa2L	/* context specific */
194 
195 /* old broken stuff */
196 #define OLD_LDAP_SUBSTRING_INITIAL	0x00L
197 #define OLD_LDAP_SUBSTRING_ANY		0x01L
198 #define OLD_LDAP_SUBSTRING_FINAL	0x02L
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 #endif /* _LDAPROT_H */
204