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.IntermediateResponseFactory.cs
27 // Anil Bhatia (banil@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using System.Reflection;
35 using Novell.Directory.Ldap;
36 using Novell.Directory.Ldap.Rfc2251;
38 namespace Novell.Directory.Ldap.Utilclass
42 /// Takes an LDAPIntermediateResponse and returns an object
43 /// (that implements the base class LDAPIntermediateResponse)
46 /// You can then call methods defined in the child
47 /// class to parse the contents of the response. The methods available
48 /// depend on the child class. All child classes inherit from the
49 /// LdapIntermediateResponse.
52 public class IntermediateResponseFactory
56 * Used to Convert an RfcLDAPMessage object to the appropriate
57 * LDAPIntermediateResponse object depending on the operation being performed.
59 * @param inResponse The LDAPIntermediateResponse object as returned by the
60 * extendedOperation method in the LDAPConnection object.
62 * @return An object of base class LDAPIntermediateResponse. The actual child
63 * 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 LdapIntermediateResponse convertToIntermediateResponse(RfcLdapMessage inResponse)
71 // throws LDAPException
74 LdapIntermediateResponse tempResponse = new LdapIntermediateResponse(inResponse);
75 // Get the oid stored in the Extended response
76 String inOID = tempResponse.getID();
78 RespExtensionSet regExtResponses =
79 LdapIntermediateResponse.getRegisteredResponses();
81 Type extRespClass = regExtResponses.findResponseExtension(inOID);
82 if ( extRespClass == null ){
86 Type[] argsClass = new Type[]{typeof(RfcLdapMessage)};
87 Object[] args = { inResponse };
90 ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass);
94 resp = extConstructor.Invoke(args);
95 return (LdapIntermediateResponse) resp;
96 } catch (UnauthorizedAccessException e) {
98 } catch (TargetInvocationException e) {
101 } catch (MissingMethodException e) {
102 // bad class was specified, fall through and return a
103 // default LDAPIntermediateResponse object
106 } catch (MissingFieldException e) {
107 // No match with the OID
108 // Do nothing. Fall through and construct a default LDAPControl object.
111 // If we get here we did not have a registered extendedresponse
112 // for this oid. Return a default LDAPIntermediateResponse object.