blob: f9a66f47a7e5c4bdee8e2fc102dd324babac27b6 (
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
|
/* 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/. */
const EXPORTED_SYMBOLS = ["LDAPConnection"];
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"LDAPClient",
"resource:///modules/LDAPClient.jsm"
);
/**
* A module to manage LDAP connection.
*
* @implements {nsILDAPConnection}
*/
class LDAPConnection {
QueryInterface = ChromeUtils.generateQI(["nsILDAPConnection"]);
get bindName() {
return this._bindName;
}
init(url, bindName, listener, closure, version) {
let useSecureTransport = url.scheme == "ldaps";
let port = url.port;
if (port == -1) {
// -1 corresponds to the protocol's default port.
port = useSecureTransport ? 636 : 389;
}
this.client = new lazy.LDAPClient(url.host, port, useSecureTransport);
this._url = url;
this._bindName = bindName;
this.client.onOpen = () => {
listener.onLDAPInit();
};
this.client.onError = (status, secInfo) => {
listener.onLDAPError(status, secInfo, `${url.host}:${port}`);
};
this.client.connect();
}
get wrappedJSObject() {
return this;
}
}
LDAPConnection.prototype.classID = Components.ID(
"{f87b71b5-2a0f-4b37-8e4f-3c899f6b8432}"
);
|