3 using Novell.Directory.Ldap;
4 using Novell.Directory.Ldap.Extensions;
5 using Novell.Directory.Ldap.Rfc2251;
8 namespace Novell.Directory.Ldap.Utilclass
12 /// Takes an LdapExtendedResponse and returns an object
13 /// (that implements the base class ParsedExtendedResponse)
16 /// <p>You can then call methods defined in the child
17 /// class to parse the contents of the response. The methods available
18 /// depend on the child class. All child classes inherit from the
19 /// ParsedExtendedResponse.</p>
22 public class ExtResponseFactory
25 /// <summary> Used to Convert an RfcLdapMessage object to the appropriate
26 /// LdapExtendedResponse object depending on the operation being performed.
29 /// <param name="inResponse"> The LdapExtendedReponse object as returned by the
30 /// extendedOperation method in the LdapConnection object.
32 /// <returns> An object of base class LdapExtendedResponse. The actual child
33 /// class of this returned object depends on the operation being
37 static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
40 LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);
41 // Get the oid stored in the Extended response
42 System.String inOID = tempResponse.ID;
44 RespExtensionSet regExtResponses = LdapExtendedResponse.RegisteredResponses;
47 System.Type extRespClass = regExtResponses.findResponseExtension(inOID);
48 if (extRespClass == null)
52 System.Type[] argsClass = new System.Type[]{typeof(RfcLdapMessage)};
53 System.Object[] args = new System.Object[]{inResponse};
57 System.Reflection.ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass);
60 System.Object resp = null;
61 resp = extConstructor.Invoke(args);
62 return (LdapExtendedResponse) resp;
64 catch (System.UnauthorizedAccessException e)
68 catch (System.Reflection.TargetInvocationException e)
72 catch (System.Exception e)
74 // Could not create the ResponseControl object
75 // All possible exceptions are ignored. We fall through
76 // and create a default LdapControl object
80 catch (System.MethodAccessException e)
82 // bad class was specified, fall through and return a
83 // default LdapExtendedResponse object
87 catch (System.FieldAccessException e)
90 // If we get here we did not have a registered extendedresponse
91 // for this oid. Return a default LdapExtendedResponse object.