| 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: |
| 11 |
* |
| 12 |
* The above copyright notice and this permission notice shall be included in |
| 13 |
* all copies or substantial portions of the Software. |
| 14 |
* |
| 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 |
*******************************************************************************/ |
| 23 |
// |
| 24 |
// Novell.Directory.Ldap.Rfc2251.RfcBindRequest.cs |
| 25 |
// |
| 26 |
// Author: |
| 27 |
// Sunil Kumar ([email protected]) |
| 28 |
// |
| 29 |
// (C) 2003 Novell, Inc (http://www.novell.com) |
| 30 |
// |
| 31 |
|
| 32 |
using System; |
| 33 |
using Novell.Directory.Ldap.Asn1; |
| 34 |
using Novell.Directory.Ldap; |
| 35 |
|
| 36 |
namespace Novell.Directory.Ldap.Rfc2251 |
| 37 |
{ |
| 38 |
|
| 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 |
| 48 |
{ |
| 49 |
/// <summary> </summary> |
| 50 |
/// <summary> Sets the protocol version</summary> |
| 51 |
virtual public Asn1Integer Version |
| 52 |
{ |
| 53 |
get |
| 54 |
{ |
| 55 |
return (Asn1Integer) get_Renamed(0); |
| 56 |
} |
| 57 |
|
| 58 |
set |
| 59 |
{ |
| 60 |
set_Renamed(0, value); |
| 61 |
return ; |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
/// <summary> </summary> |
| 66 |
/// <summary> </summary> |
| 67 |
virtual public RfcLdapDN Name |
| 68 |
{ |
| 69 |
get |
| 70 |
{ |
| 71 |
return (RfcLdapDN) get_Renamed(1); |
| 72 |
} |
| 73 |
|
| 74 |
set |
| 75 |
{ |
| 76 |
set_Renamed(1, value); |
| 77 |
return ; |
| 78 |
} |
| 79 |
|
| 80 |
} |
| 81 |
/// <summary> </summary> |
| 82 |
/// <summary> </summary> |
| 83 |
virtual public RfcAuthenticationChoice AuthenticationChoice |
| 84 |
{ |
| 85 |
get |
| 86 |
{ |
| 87 |
return (RfcAuthenticationChoice) get_Renamed(2); |
| 88 |
} |
| 89 |
|
| 90 |
set |
| 91 |
{ |
| 92 |
set_Renamed(2, value); |
| 93 |
return ; |
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
|
| 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); |
| 104 |
|
| 105 |
|
| 106 |
//************************************************************************* |
| 107 |
// Constructors for BindRequest |
| 108 |
//************************************************************************* |
| 109 |
|
| 110 |
/// <summary> </summary> |
| 111 |
public RfcBindRequest(Asn1Integer version, RfcLdapDN name, RfcAuthenticationChoice auth):base(3) |
| 112 |
{ |
| 113 |
add(version); |
| 114 |
add(name); |
| 115 |
add(auth); |
| 116 |
return ; |
| 117 |
} |
| 118 |
|
| 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)) |
| 121 |
{ |
| 122 |
} |
| 123 |
|
| 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) |
| 129 |
{ |
| 130 |
// Replace the dn if specified, otherwise keep original base |
| 131 |
if ((System.Object) base_Renamed != null) |
| 132 |
{ |
| 133 |
set_Renamed(1, new RfcLdapDN(base_Renamed)); |
| 134 |
} |
| 135 |
return ; |
| 136 |
} |
| 137 |
|
| 138 |
//************************************************************************* |
| 139 |
// Mutators |
| 140 |
//************************************************************************* |
| 141 |
|
| 142 |
//************************************************************************* |
| 143 |
// Accessors |
| 144 |
//************************************************************************* |
| 145 |
|
| 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() |
| 153 |
{ |
| 154 |
return ID; |
| 155 |
} |
| 156 |
|
| 157 |
public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request) |
| 158 |
{ |
| 159 |
return new RfcBindRequest(toArray(), base_Renamed); |
| 160 |
} |
| 161 |
public System.String getRequestDN() |
| 162 |
{ |
| 163 |
return ((RfcLdapDN) get_Renamed(1)).stringValue(); |
| 164 |
} |
| 165 |
} |
| 166 |
} |