Debian Codegraph @

mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountResponse.cs

raw
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.Extensions.PartitionEntryCountResponse.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;
34 using Novell.Directory.Ldap.Asn1;
35 using Novell.Directory.Ldap.Utilclass;
36 using Novell.Directory.Ldap.Rfc2251;
37 namespace Novell.Directory.Ldap.Extensions
38 {
39
40 /// <summary> Returns the number of entries in the partition.
41 ///
42 /// An object in this class is generated from an ExtendedResponse object
43 /// using the ExtendedResponseFactory class.
44 ///
45 /// The PartitionEntryCountResponse extension uses the following
46 /// OID:
47 /// 2.16.840.1.113719.1.27.100.14
48 ///
49 /// </summary>
50 public class PartitionEntryCountResponse:LdapExtendedResponse
51 {
52 /// <summary> Returns the number of entries in the naming context.
53 ///
54 /// </summary>
55 /// <returns> The count of the number of objects returned.
56 /// </returns>
57 virtual public int Count
58 {
59 get
60 {
61 return count;
62 }
63
64 }
65
66 //The count of the objects returned by the server is saved here
67 private int count;
68
69 /// <summary> Constructs an object from the responseValue which contains the
70 /// entry count.
71 ///
72 /// The constructor parses the responseValue which has the following
73 /// format:
74 /// responseValue ::=
75 /// count INTEGER
76 ///
77 /// </summary>
78 /// <exception> IOException The response value could not be decoded.
79 /// </exception>
80 public PartitionEntryCountResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
81 {
82
83 if (ResultCode == LdapException.SUCCESS)
84 {
85 // parse the contents of the reply
86 sbyte[] returnedValue = this.Value;
87 if (returnedValue == null)
88 throw new System.IO.IOException("No returned value");
89
90 // Create a decoder object
91 LBERDecoder decoder = new LBERDecoder();
92 if (decoder == null)
93 throw new System.IO.IOException("Decoding error");
94
95 Asn1Integer asn1_count = (Asn1Integer) decoder.decode(returnedValue);
96 if (asn1_count == null)
97 throw new System.IO.IOException("Decoding error");
98
99 count = asn1_count.intValue();
100 }
101 else
102 {
103 count = - 1;
104 }
105 }
106 }
107 }