1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
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
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Utilclass.ExtResponseFactory.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Novell.Directory.Ldap;
34 using Novell.Directory.Ldap.Extensions;
35 using Novell.Directory.Ldap.Rfc2251;
37 namespace Novell.Directory.Ldap.Utilclass
40 /// Takes an LdapExtendedResponse and returns an object
41 /// (that implements the base class ParsedExtendedResponse)
44 /// You can then call methods defined in the child
45 /// class to parse the contents of the response. The methods available
46 /// depend on the child class. All child classes inherit from the
47 /// ParsedExtendedResponse.
50 public class ExtResponseFactory
53 /// <summary> Used to Convert an RfcLdapMessage object to the appropriate
54 /// LdapExtendedResponse object depending on the operation being performed.
57 /// <param name="inResponse"> The LdapExtendedReponse object as returned by the
58 /// extendedOperation method in the LdapConnection object.
61 /// <returns> An object of base class LdapExtendedResponse. The actual child
62 /// class of this returned object depends on the operation being
66 /// <exception> LdapException A general exception which includes an error message
67 /// and an Ldap error code.
70 static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
73 LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);
75 // Get the oid stored in the Extended response
76 System.String inOID = tempResponse.ID;
78 if ((System.Object) inOID == null)
80 // Is this an OID we support, if yes then build the
81 // detailed LdapExtendedResponse object
84 if (inOID.Equals(ReplicationConstants.NAMING_CONTEXT_COUNT_RES))
86 return new PartitionEntryCountResponse(inResponse);
88 if (inOID.Equals(ReplicationConstants.GET_IDENTITY_NAME_RES))
90 return new GetBindDNResponse(inResponse);
92 if (inOID.Equals(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES))
94 return new GetEffectivePrivilegesResponse(inResponse);
96 if (inOID.Equals(ReplicationConstants.GET_REPLICA_INFO_RES))
98 return new GetReplicaInfoResponse(inResponse);
100 if (inOID.Equals(ReplicationConstants.LIST_REPLICAS_RES))
102 return new ListReplicasResponse(inResponse);
104 if (inOID.Equals(ReplicationConstants.GET_REPLICATION_FILTER_RES))
106 return new GetReplicationFilterResponse(inResponse);
111 catch (System.IO.IOException ioe)
113 throw new LdapException(ExceptionMessages.DECODING_ERROR, LdapException.DECODING_ERROR, (System.String) null);