This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
errors.html
123 lines (112 loc) · 4.74 KB
/
errors.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Errors API | ldapjs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="media/css/style.css">
<link rel="stylesheet" type="text/css" href="media/css/highlight.css">
</head>
<body>
<div id="header">
<h1>Errors API | ldapjs Documentation</h1>
</div>
<div id="sidebar">
<div>Sections</div>
<span>
<ul>
<li><div><a href="index.html">Home</a></div></li>
<li><div><a href="guide.html">Guide</a></div></li>
<li><div><a href="examples.html">Examples</a></div></li>
<li><div><a href="client.html">Client API</a></div></li>
<li><div><a href="server.html">Server API</a></div></li>
<li><div><a href="dn.html">DN API</a></div></li>
<li><div><a href="filters.html">Filters API</a></div></li>
<li><div><a href="errors.html">Error API</a></div></li>
</ul>
</span>
<div>Contents</div>
</span>
<ul>
<li>
<div>
<a href="#complete-list-of-ldaperror-subclasses">Complete list of LDAPError subclasses</a>
</div>
</li>
</ul>
</div>
<div id="content">
<h1 id="ldapjs-errors-api">ldapjs Errors API</h1>
<div class="intro">
<p>This document covers the ldapjs errors API and assumes that you are familiar
with LDAP. If you're not, read the <a href="guide.html">guide</a> first.</p>
</div>
<p>All errors in the ldapjs framework extend from an abstract error type called
<code>LDAPError</code>. In addition to the properties listed below, all errors will have
a <code>stack</code> property correctly set.</p>
<p>In general, you'll be using the errors in ldapjs like:</p>
<pre><code class="language-js"><span class="hljs-keyword">const</span> ldap = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ldapjs'</span>);
<span class="hljs-keyword">const</span> db = {};
server.<span class="hljs-title function_">add</span>(<span class="hljs-string">'o=example'</span>, <span class="hljs-function">(<span class="hljs-params">req, res, next</span>) =></span> {
<span class="hljs-keyword">const</span> parent = req.<span class="hljs-property">dn</span>.<span class="hljs-title function_">parent</span>();
<span class="hljs-keyword">if</span> (parent) {
<span class="hljs-keyword">if</span> (!db[parent.<span class="hljs-title function_">toString</span>()])
<span class="hljs-keyword">return</span> <span class="hljs-title function_">next</span>(<span class="hljs-keyword">new</span> ldap.<span class="hljs-title class_">NoSuchObjectError</span>(parent.<span class="hljs-title function_">toString</span>()));
}
<span class="hljs-keyword">if</span> (db[req.<span class="hljs-property">dn</span>.<span class="hljs-title function_">toString</span>()])
<span class="hljs-keyword">return</span> <span class="hljs-title function_">next</span>(<span class="hljs-keyword">new</span> ldap.<span class="hljs-title class_">EntryAlreadyExistsError</span>(req.<span class="hljs-property">dn</span>.<span class="hljs-title function_">toString</span>()));
...
});
</code></pre>
<p>I.e., if you just pass them into the <code>next()</code> handler, ldapjs will automatically
return the appropriate LDAP error message, and stop the handler chain.</p>
<p>All errors will have the following properties:</p>
<h2 id="code">code</h2>
<p>Returns the LDAP status code associated with this error.</p>
<h2 id="name">name</h2>
<p>The name of this error.</p>
<h2 id="message">message</h2>
<p>The message that will be returned to the client.</p>
<h1 id="complete-list-of-ldaperror-subclasses">Complete list of LDAPError subclasses</h1>
<ul>
<li>OperationsError</li>
<li>ProtocolError</li>
<li>TimeLimitExceededError</li>
<li>SizeLimitExceededError</li>
<li>CompareFalseError</li>
<li>CompareTrueError</li>
<li>AuthMethodNotSupportedError</li>
<li>StrongAuthRequiredError</li>
<li>ReferralError</li>
<li>AdminLimitExceededError</li>
<li>UnavailableCriticalExtensionError</li>
<li>ConfidentialityRequiredError</li>
<li>SaslBindInProgressError</li>
<li>NoSuchAttributeError</li>
<li>UndefinedAttributeTypeError</li>
<li>InappropriateMatchingError</li>
<li>ConstraintViolationError</li>
<li>AttributeOrValueExistsError</li>
<li>InvalidAttriubteSyntaxError</li>
<li>NoSuchObjectError</li>
<li>AliasProblemError</li>
<li>InvalidDnSyntaxError</li>
<li>AliasDerefProblemError</li>
<li>InappropriateAuthenticationError</li>
<li>InvalidCredentialsError</li>
<li>InsufficientAccessRightsError</li>
<li>BusyError</li>
<li>UnavailableError</li>
<li>UnwillingToPerformError</li>
<li>LoopDetectError</li>
<li>NamingViolationError</li>
<li>ObjectclassViolationError</li>
<li>NotAllowedOnNonLeafError</li>
<li>NotAllowedOnRdnError</li>
<li>EntryAlreadyExistsError</li>
<li>ObjectclassModsProhibitedError</li>
<li>AffectsMultipleDsasError</li>
<li>OtherError</li>
</ul>
</div><!-- end #content -->
</body>
</html>