**** Merged from MCS ****
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Rfc2251 / RfcBindRequest.cs
blobf04146c81efb6731923f7c25b51a824bac78e89d
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc. www.novell.com
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Rfc2251.RfcBindRequest.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
33 using Novell.Directory.Ldap.Asn1;
34 using Novell.Directory.Ldap;
36 namespace Novell.Directory.Ldap.Rfc2251
39 /// <summary> Represents and Ldap Bind Request.
40 /// <pre>
41 /// BindRequest ::= [APPLICATION 0] SEQUENCE {
42 /// version INTEGER (1 .. 127),
43 /// name LdapDN,
44 /// authentication AuthenticationChoice }
45 /// </pre>
46 /// </summary>
47 public class RfcBindRequest:Asn1Sequence, RfcRequest
49 /// <summary> </summary>
50 /// <summary> Sets the protocol version</summary>
51 virtual public Asn1Integer Version
53 get
55 return (Asn1Integer) get_Renamed(0);
58 set
60 set_Renamed(0, value);
61 return ;
65 /// <summary> </summary>
66 /// <summary> </summary>
67 virtual public RfcLdapDN Name
69 get
71 return (RfcLdapDN) get_Renamed(1);
74 set
76 set_Renamed(1, value);
77 return ;
81 /// <summary> </summary>
82 /// <summary> </summary>
83 virtual public RfcAuthenticationChoice AuthenticationChoice
85 get
87 return (RfcAuthenticationChoice) get_Renamed(2);
90 set
92 set_Renamed(2, value);
93 return ;
98 /// <summary> ID is added for Optimization.
99 ///
100 /// ID needs only be one Value for every instance,
101 /// thus we create it only once.
102 /// </summary>
103 new private static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.BIND_REQUEST);
106 //*************************************************************************
107 // Constructors for BindRequest
108 //*************************************************************************
110 /// <summary> </summary>
111 public RfcBindRequest(Asn1Integer version, RfcLdapDN name, RfcAuthenticationChoice auth):base(3)
113 add(version);
114 add(name);
115 add(auth);
116 return ;
119 [CLSCompliantAttribute(false)]
120 public RfcBindRequest(int version, System.String dn, System.String mechanism, sbyte[] credentials):this(new Asn1Integer(version), new RfcLdapDN(dn), new RfcAuthenticationChoice(mechanism, credentials))
124 /// <summary> Constructs a new Bind Request copying the original data from
125 /// an existing request.
126 /// </summary>
127 /* package */
128 internal RfcBindRequest(Asn1Object[] origRequest, System.String base_Renamed):base(origRequest, origRequest.Length)
130 // Replace the dn if specified, otherwise keep original base
131 if ((System.Object) base_Renamed != null)
133 set_Renamed(1, new RfcLdapDN(base_Renamed));
135 return ;
138 //*************************************************************************
139 // Mutators
140 //*************************************************************************
142 //*************************************************************************
143 // Accessors
144 //*************************************************************************
146 /// <summary> Override getIdentifier to return an application-wide id.
147 ///
148 /// <pre>
149 /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 0. (0x60)
150 /// </pre>
151 /// </summary>
152 public override Asn1Identifier getIdentifier()
154 return ID;
157 public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
159 return new RfcBindRequest(toArray(), base_Renamed);
161 public System.String getRequestDN()
163 return ((RfcLdapDN) get_Renamed(1)).stringValue();