New test.
[mono.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap / LdapBindRequest.cs
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.LdapBindRequest.cs
25 //
26 // Author:
27 //   Sunil Kumar (Sunilk@novell.com)
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.Rfc2251;
35 namespace Novell.Directory.Ldap
36 {
37         
38         /// <summary> Represents a simple bind request.
39         /// 
40         /// </summary>
41         /// <seealso cref="LdapConnection.SendRequest">
42         /// </seealso>
43    /*
44         *       BindRequest ::= [APPLICATION 0] SEQUENCE {
45         *               version                 INTEGER (1 .. 127),
46         *               name                    LdapDN,
47         *               authentication          AuthenticationChoice }
48         */
49         public class LdapBindRequest:LdapMessage
50         {
51                 /// <summary> Retrieves the Authentication DN for a bind request.
52                 /// 
53                 /// </summary>
54                 /// <returns> the Authentication DN for a bind request
55                 /// </returns>
56                 virtual public System.String AuthenticationDN
57                 {
58                         get
59                         {
60                                 return Asn1Object.RequestDN;
61                         }
62                         
63                 }
64                 /// <summary> Constructs a simple bind request.
65                 /// 
66                 /// </summary>
67                 /// <param name="version"> The Ldap protocol version, use Ldap_V3.
68                 /// Ldap_V2 is not supported.
69                 /// 
70                 /// </param>
71                 /// <param name="dn">     If non-null and non-empty, specifies that the
72                 /// connection and all operations through it should
73                 /// be authenticated with dn as the distinguished
74                 /// name.
75                 /// 
76                 /// </param>
77                 /// <param name="passwd"> If non-null and non-empty, specifies that the
78                 /// connection and all operations through it should
79                 /// be authenticated with dn as the distinguished
80                 /// name and passwd as password.
81                 /// 
82                 /// </param>
83                 /// <param name="cont">Any controls that apply to the simple bind request,
84                 /// or null if none.
85                 /// </param>
86                 [CLSCompliantAttribute(false)]
87                 public LdapBindRequest(int version, System.String dn, sbyte[] passwd, LdapControl[] cont):base(LdapMessage.BIND_REQUEST, new RfcBindRequest(new Asn1Integer(version), new RfcLdapDN(dn), new RfcAuthenticationChoice(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, 0), new Asn1OctetString(passwd), false))), cont)
88                 {
89                         return ;
90                 }
91
92                 /// <summary> Constructs a secure bind request.
93                 /// 
94                 /// </summary>
95                 /// <param name="version"> The Ldap protocol version, use Ldap_V3.
96                 /// Ldap_V2 is not supported.
97                 /// 
98                 /// </param>
99                 /// <param name="dn">     If non-null and non-empty, specifies that the
100                 /// connection and all operations through it should
101                 /// be authenticated with dn as the distinguished
102                 /// name.
103                 /// 
104                 /// </param>
105                 /// <param name="mechanism"> Security mechanism code
106                 /// 
107                 /// </param>
108                 /// <param name="passwd"> Security credentials
109                 /// 
110                 /// </param>
111                 /// <param name="cont">Any controls that apply to the simple bind request,
112                 /// or null if none.
113                 /// </param>
114                 [CLSCompliantAttribute(false)]
115                 public LdapBindRequest(int version, System.String dn, String mechanism, sbyte[] credentials, LdapControl[]              
116                 cont):base(LdapMessage.BIND_REQUEST, new RfcBindRequest(version, dn, mechanism, credentials), cont)
117                 {
118                         return ;
119                 }
120                 
121                 /// <summary> Return an Asn1 representation of this add request.
122                 /// 
123                 /// #return an Asn1 representation of this object.
124                 /// </summary>
125                 public override System.String ToString()
126                 {
127                         return Asn1Object.ToString();
128                 }
129         }
130 }