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.Events.Edir.MonitorEventRequest.cs
27 // Anil Bhatia (banil@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
36 using Novell
.Directory
.Ldap
.Utilclass
;
37 using Novell
.Directory
.Ldap
.Asn1
;
39 namespace Novell
.Directory
.Ldap
.Events
.Edir
42 /// This class denotes the mechanism to specify the event of interest.
44 public class MonitorEventRequest
: LdapExtendedOperation
46 static MonitorEventRequest()
49 * Register the extendedresponse class which is returned by the
50 * server in response to a MonitorEventRequest
54 LdapExtendedResponse
.register(EventOids
.NLDAP_MONITOR_EVENTS_RESPONSE
,
55 Type
.GetType("Novell.Directory.Ldap.Events.Edir.MonitorEventResponse", true));
57 catch(TypeLoadException e
)
59 // TODO: put something in the Debug...
63 // TODO: put something in the Debug...
66 //Also try to register EdirEventIntermediateResponse
69 LdapIntermediateResponse
.register(EventOids
.NLDAP_EVENT_NOTIFICATION
,
70 Type
.GetType("Novell.Directory.Ldap.Events.Edir.EdirEventIntermediateResponse", true));
72 catch(TypeLoadException e
)
74 // TODO: put something in the Debug...
78 // TODO: put something in the Debug...
80 } // end of static constructor
82 public MonitorEventRequest(EdirEventSpecifier
[] specifiers
) :
83 base(EventOids
.NLDAP_MONITOR_EVENTS_REQUEST
, null)
85 if ((specifiers
== null))
87 throw new ArgumentException(ExceptionMessages
.PARAM_ERROR
);
90 MemoryStream encodedData
= new MemoryStream();
91 LBEREncoder encoder
= new LBEREncoder();
93 Asn1Sequence asnSequence
= new Asn1Sequence();
96 asnSequence
.add(new Asn1Integer(specifiers
.Length
));
98 Asn1Set asnSet
= new Asn1Set();
99 bool bFiltered
= false;
100 for (int nIndex
= 0; nIndex
< specifiers
.Length
; nIndex
++)
102 Asn1Sequence specifierSequence
= new Asn1Sequence();
103 specifierSequence
.add(new Asn1Integer((int)(specifiers
[nIndex
].EventType
)));
104 specifierSequence
.add(new Asn1Enumerated((int)(specifiers
[nIndex
].EventResultType
)));
107 bFiltered
= (null != specifiers
[nIndex
].EventFilter
);
109 setID(EventOids
.NLDAP_FILTERED_MONITOR_EVENTS_REQUEST
);
114 // A filter is expected
115 if (null == specifiers
[nIndex
].EventFilter
)
116 throw new ArgumentException("Filter cannot be null,for Filter events");
118 specifierSequence
.add(new Asn1OctetString(specifiers
[nIndex
].EventFilter
));
122 // No filter is expected
123 if (null != specifiers
[nIndex
].EventFilter
)
124 throw new ArgumentException("Filter cannot be specified for non Filter events");
127 asnSet
.add(specifierSequence
);
130 asnSequence
.add(asnSet
);
131 asnSequence
.encode(encoder
, encodedData
);
135 throw new LdapException(ExceptionMessages
.ENCODING_ERROR
,
136 LdapException
.ENCODING_ERROR
,
140 setValue(SupportClass
.ToSByteArray(encodedData
.ToArray()));
141 } // end of the constructor MonitorEventRequest