summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/addrbook/public/nsILDAPURL.idl
blob: fd0c3e28eca88cc585fca65fd021a8d9107309ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsIURI.idl"

%{C++
#define NS_LDAPURL_CONTRACTID "@mozilla.org/network/ldap-url;1"
%}

/**
 * Strings in methods inherited from nsIURI, which are using XPIDL
 * |string| types, are expected to be UTF8 encoded. All such strings
 * in this interface, except attribute types (e.g. "cn"), should in fact
 * be UTF8. It's important to remember that attributes can not be UTF8,
 * they can only be of a limited subset of ASCII (see RFC 2251).
 */

[scriptable, builtinclass, uuid(8e3a6d33-2e68-40ba-8f94-6ac03f69066e)]
interface nsILDAPURL : nsIURI {
    /**
     * Initialize an LDAP URL
     *
     * @param aUrlType       - one of the URLTYPE_ flags @seealso nsIStandardURL
     * @param aDefaultPort   - if the port parsed from the URL string matches
     *                         this port, then the port will be removed from the
     *                         canonical form of the URL.
     * @param aSpec          - URL string.
     * @param aOriginCharset - the charset from which this URI string
     *                         originated.  this corresponds to the charset
     *                         that should be used when communicating this
     *                         URI to an origin server, for example.  if
     *                         null, then provide aBaseURI implements this
     *                         interface, the origin charset of aBaseURI will
     *                         be assumed, otherwise defaulting to UTF-8 (i.e.,
     *                         no charset transformation from aSpec).
     * @param aBaseURI       - if null, aSpec must specify an absolute URI.
     *                         otherwise, aSpec will be resolved relative
     *                         to aBaseURI.
     */
    void init(in unsigned long aUrlType,
              in long aDefaultPort,
              in AUTF8String aSpec,
              in string aOriginCharset,
              in nsIURI aBaseURI);

    /**
     * The distinguished name of the URL (ie the base DN for the search).
     * This string is expected to be a valid UTF8 string.
     *
     * for the getter:
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_OUT_OF_MEMORY    Ran out of memory
     */
    attribute AUTF8String dn;

    /**
     * The attributes to get for this URL, in comma-separated format. If the
     * list is empty, all attributes are requested.
     */
    attribute ACString attributes;

    /**
     * Add one attribute to the array of attributes to request. If the
     * attribute is already in our array, this becomes a noop.
     *
     * @param aAttribute          An LDAP attribute (e.g. "cn")
     */
    void addAttribute(in ACString aAttribute);

    /**
     * Remove one attribute from the array of attributes to request. If
     * the attribute didn't exist in the array, this becomes a noop.
     *
     * @param aAttribute                    An LDAP attribute (e.g. "cn")
     * @exception NS_ERROR_OUT_OF_MEMORY    Ran out of memory
     */
    void removeAttribute(in ACString aAttribute);

    /**
     * Test if an attribute is in our list of attributes already
     *
     * @param aAttribute                    An LDAP attribute (e.g. "cn")
     * @return boolean                      Truth value
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     */
    boolean hasAttribute(in ACString aAttribute);

    /**
     * The scope of the search.  defaults to SCOPE_BASE.
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_MALFORMED_URI    Illegal base to SET method
     */
    attribute long scope;

    /**
     * Search just the base object
     */
    const long SCOPE_BASE = 0;

    /**
     * Search only the children of the base object
     */
    const long SCOPE_ONELEVEL = 1;

    /**
     * Search the entire subtree under and including the base object
     */
    const long SCOPE_SUBTREE = 2;

    /**
     * The search filter. "(objectClass=*)" is the default.
     */
    attribute AUTF8String filter;

    /**
     * Any options defined for this URL (check options using a bitwise and)
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_OUT_OF_MEMORY    Ran out of memory
     */
    attribute unsigned long options;

    /**
     * If this is set/true, this is an ldaps: URL, not an ldap: URL
     */
    const unsigned long OPT_SECURE = 0x01;
};

/**
 * A structure to represent an LDAP URL.
 */
[scriptable, uuid(c0376fe9-2c7c-4f7b-a991-db9c3d95c1bb)]
interface nsILDAPURLParserResult : nsISupports {
    /** The host name of the URL. */
    readonly attribute AUTF8String host;

    /** The port number of the URL. */
    readonly attribute long port;

    /** The distinguished name of the URL. */
    readonly attribute AUTF8String dn;

    /** The attributes to request when searching. */
    readonly attribute ACString attributes;

    /** The scope to use when searching. */
    readonly attribute long scope;

    /** The filter to use when searching. */
    readonly attribute AUTF8String filter;

    /** The options of the URL. */
    readonly attribute unsigned long options;
};

/**
 * A helper module to parse a string to an LDAP URL.
 */
[scriptable, uuid(340098c0-a881-49ab-a5e8-f79d04e6651c)]
interface nsILDAPURLParser : nsISupports {
    /**
     * Parse a string to an LDAP URL.
     */
    nsILDAPURLParserResult parse(in AUTF8String aSpec);
};