diff options
author | Anil Bhatia <anil@mono-cvs.ximian.com> | 2004-12-06 17:35:32 +0300 |
---|---|---|
committer | Anil Bhatia <anil@mono-cvs.ximian.com> | 2004-12-06 17:35:32 +0300 |
commit | 92b6b35b25b9ec7b2f35b85d5223455e917c50fa (patch) | |
tree | 35e727a6e032563166065012cf52c363583b15ae /mcs/class/Novell.Directory.Ldap | |
parent | defb0bee77e7dc33cdd018e42e888717a7f850bf (diff) |
Added support for SSL, Ldap Events, Edir Events
svn path=/trunk/mcs/; revision=37195
Diffstat (limited to 'mcs/class/Novell.Directory.Ldap')
52 files changed, 4830 insertions, 160 deletions
diff --git a/mcs/class/Novell.Directory.Ldap/ChangeLog b/mcs/class/Novell.Directory.Ldap/ChangeLog index 211b04d50d0..49d3050809a 100644 --- a/mcs/class/Novell.Directory.Ldap/ChangeLog +++ b/mcs/class/Novell.Directory.Ldap/ChangeLog @@ -1,14 +1,23 @@ -2003-11-14 Sunil Kumar <sunilk@novell.com> - - * Changed the Directory structure and Class file names as per the Microsoft Standards. +2004-12-06 Anil Bhatia <banil@novell.com> - * Changed the build scripts accordingly + * Updated with support for SSL, + Ldap Events, Edir Events, Intermediate Response -2003-11-15 Sunil Kumar <sunilk@novell.com> - - * Changed the LdapConnection public Method name as per MS naming convention + * Updated ChangeLog so that latest changes are + on the top. - * Added the Authors description +2003-12-14 Sunil Kumar <sunilk@novell.com> + + * Updated with XML Doc. Support + +2003-12-09 Sunil Kumar <sunilk@novell.com> + + * Updated with Schema Support + +2003-11-21 Sunil Kumar <sunilk@novell.com> + + * Changed the linux build script to replace corlib.dll + with mscorlib.dll 2003-11-16 Sunil Kumar <sunilk@novell.com> @@ -16,15 +25,19 @@ * Added Samples for LDAP controls -2003-11-21 Sunil Kumar <sunilk@novell.com> +2003-11-15 Sunil Kumar <sunilk@novell.com> + + * Changed the LdapConnection public Method name as per MS naming convention + + * Added the Authors description + +2003-11-14 Sunil Kumar <sunilk@novell.com> + + * Changed the Directory structure and Class file names as per the Microsoft Standards. + + * Changed the build scripts accordingly - * Changed the linux build script to replace corlib.dll - with mscorlib.dll -2003-12-09 Sunil Kumar <sunilk@novell.com> - * Updated with Schema Support -2003-12-14 Sunil Kumar <sunilk@novell.com> - * Updated with XML Doc. Support diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/BaseEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/BaseEventArgs.cs new file mode 100644 index 00000000000..5e184e6ca33 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/BaseEventArgs.cs @@ -0,0 +1,59 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.BaseEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This is the base class for other EventArgs representing exception + /// and normal events. + /// </summary> + /// <seealso cref='Novell.Directory.Ldap.Events.DirectoryExceptionEventArgs'/> + /// <seealso cref='Novell.Directory.Ldap.Events.DirectoryEventArgs'/> + public class BaseEventArgs : EventArgs + { + protected LdapMessage ldap_message; + public LdapMessage ContianedEventInformation + { + get + { + return ldap_message; + } + } + + public BaseEventArgs(LdapMessage message) + { + ldap_message = message; + } + + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryEventArgs.cs new file mode 100644 index 00000000000..1d625390302 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryEventArgs.cs @@ -0,0 +1,63 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.DirectoryEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This is the base class for other EventArgs corresponding to + /// Ldap and Edir events. + /// </summary> + /// <seealso cref='Novell.Directory.Ldap.Events.LdapEventArgs'/> + /// <seealso cref='Novell.Directory.Ldap.Events.Edir.EdirEventArgs'/> + public class DirectoryEventArgs : BaseEventArgs + { + protected EventClassifiers eClassification; + public EventClassifiers EventClassification + { + get + { + return eClassification; + } + set + { + eClassification = value; + } + } + + public DirectoryEventArgs(LdapMessage sourceMessage, + EventClassifiers aClassification) + : base(sourceMessage) + { + eClassification = aClassification; + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryExceptionEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryExceptionEventArgs.cs new file mode 100644 index 00000000000..3e099e28647 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/DirectoryExceptionEventArgs.cs @@ -0,0 +1,59 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.DirectoryExceptionEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This class gives the EventArgs for Directory exceptions. + /// </summary> + /// <seealso cref='Novell.Directory.Ldap.Events.LdapEventArgs'/> + /// <seealso cref='Novell.Directory.Ldap.Events.Edir.EdirEventArgs'/> + public class DirectoryExceptionEventArgs : BaseEventArgs + { + protected LdapException ldap_exception_object; + public LdapException LdapExceptionObject + { + get + { + return ldap_exception_object; + } + } + + public DirectoryExceptionEventArgs(LdapMessage message, LdapException ldapException) + : base(message) + { + ldap_exception_object = ldapException; + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventArgs.cs new file mode 100644 index 00000000000..2ef61946712 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventArgs.cs @@ -0,0 +1,83 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.LdapEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; +using System.Text; + +using Novell.Directory.Ldap.Controls; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This class represents the EventArgs for Ldap events in general. + /// This is also the base class for more specific Ldap events. + /// </summary> + /// <seealso cref='Novell.Directory.Ldap.Events.SearchResultEventArgs'/> + /// <seealso cref='Novell.Directory.Ldap.Events.SearchReferralEventArgs'/> + public class LdapEventArgs : DirectoryEventArgs + { + protected LdapEventType eType; + public LdapEventType EventType + { + get + { + return eType; + } + set + { + eType = value; + } + } + + public LdapEventArgs( + LdapMessage sourceMessage, + EventClassifiers aClassification, + LdapEventType aType) + : base(sourceMessage, aClassification) + { + eType = aType; + } + + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("["); + buf.AppendFormat("{0}:", GetType()); + buf.AppendFormat("(Classification={0})", eClassification); + buf.AppendFormat("(Type={0})", eType); + buf.AppendFormat("(EventInformation:{0})", ldap_message); + buf.Append("]"); + + return buf.ToString(); + } + } // end of class LdapEventArgs +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventConstants.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventConstants.cs new file mode 100644 index 00000000000..f9fa0fcc1d6 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventConstants.cs @@ -0,0 +1,59 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.LdapEventConstants.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using Novell.Directory.Ldap.Controls; + +namespace Novell.Directory.Ldap.Events +{ + + /// <summary> + /// Event Classifiers + /// </summary> + public enum EventClassifiers + { + CLASSIFICATION_UNKNOWN = -1, + CLASSIFICATION_LDAP_PSEARCH = 0, + CLASSIFICATION_EDIR_EVENT = 1 + } + + /// <summary> + /// Types of Ldap Events + /// </summary> + public enum LdapEventType + { + TYPE_UNKNOWN = LdapEventSource.EVENT_TYPE_UNKNOWN, + LDAP_PSEARCH_ADD = LdapPersistSearchControl.ADD, + LDAP_PSEARCH_DELETE = LdapPersistSearchControl.DELETE, + LDAP_PSEARCH_MODIFY = LdapPersistSearchControl.MODIFY, + LDAP_PSEARCH_MODDN = LdapPersistSearchControl.MODDN, + LDAP_PSEARCH_ANY = LDAP_PSEARCH_ADD | LDAP_PSEARCH_DELETE | LDAP_PSEARCH_MODIFY | LDAP_PSEARCH_MODDN + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventSource.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventSource.cs new file mode 100644 index 00000000000..82731d97a85 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/LdapEventSource.cs @@ -0,0 +1,390 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.LdapEventSource.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; +using System.Threading; + +using Novell.Directory.Ldap; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This is the base class for any EventSource. + /// </summary> + /// <seealso cref='Novell.Directory.Ldap.Events.PSearchEventSource'/> + /// <seealso cref='Novell.Directory.Ldap.Events.Edir.EdirEventSource'/> + public abstract class LdapEventSource + { + protected enum LISTENERS_COUNT + { + ZERO, + ONE, + MORE_THAN_ONE + } + + internal protected const int EVENT_TYPE_UNKNOWN = -1; + protected const int DEFAULT_SLEEP_TIME = 1000; + + protected int sleep_interval = DEFAULT_SLEEP_TIME; + + /// <summary> + /// SleepInterval controls the duration after which event polling is repeated. + /// </summary> + public int SleepInterval + { + get + { + return sleep_interval; + } + set + { + sleep_interval = value; + } + } + + protected abstract int GetListeners(); + + protected LISTENERS_COUNT GetCurrentListenersState() + { + int nListeners = 0; + + // Get Listeners registered with Actual EventSource + nListeners += GetListeners(); + + // Get Listeners registered for generic events + if (null != directory_event) + nListeners += directory_event.GetInvocationList().Length; + + // Get Listeners registered for exception events + if (null != directory_exception_event) + nListeners += directory_exception_event.GetInvocationList().Length; + + if (0 == nListeners) + return LISTENERS_COUNT.ZERO; + + if (1 == nListeners) + return LISTENERS_COUNT.ONE; + + return LISTENERS_COUNT.MORE_THAN_ONE; + } + + protected void ListenerAdded() + { + // Get current state + LISTENERS_COUNT lc = GetCurrentListenersState(); + + switch (lc) + { + case LISTENERS_COUNT.ONE: + // start search and polling if not already started + StartSearchAndPolling(); + break; + + case LISTENERS_COUNT.ZERO: + case LISTENERS_COUNT.MORE_THAN_ONE: + default: + break; + } + } + + protected void ListenerRemoved() + { + // Get current state + LISTENERS_COUNT lc = GetCurrentListenersState(); + + switch (lc) + { + case LISTENERS_COUNT.ZERO: + // stop search and polling if not already stopped + StopSearchAndPolling(); + break; + + case LISTENERS_COUNT.ONE: + case LISTENERS_COUNT.MORE_THAN_ONE: + default: + break; + } + } + + protected abstract void StartSearchAndPolling(); + protected abstract void StopSearchAndPolling(); + + protected DirectoryEventHandler directory_event; + + /// <summary> + /// DirectoryEvent represents a generic Directory event. + /// If any event is not recognized by the actual + /// event sources, an object of corresponding DirectoryEventArgs + /// class is passed as part of the notification. + /// </summary> + public event DirectoryEventHandler DirectoryEvent + { + add + { + directory_event += value; + ListenerAdded(); + } + remove + { + directory_event -= value; + ListenerRemoved(); + } + } + + /// <summary> + /// DirectoryEventHandler is the delegate definition for DirectoryEvent. + /// The client (listener) has to register using this delegate in order to + /// get events that may not be recognized by the actual event source. + /// </summary> + public delegate void DirectoryEventHandler(object source, DirectoryEventArgs objDirectoryEventArgs); + + protected DirectoryExceptionEventHandler directory_exception_event; + /// <summary> + /// DirectoryEvent represents a generic Directory exception event. + /// </summary> + public event DirectoryExceptionEventHandler DirectoryExceptionEvent + { + add + { + directory_exception_event += value; + ListenerAdded(); + } + remove + { + directory_exception_event -= value; + ListenerRemoved(); + } + } + + /// <summary> + /// DirectoryEventHandler is the delegate definition for DirectoryExceptionEvent. + /// </summary> + public delegate void DirectoryExceptionEventHandler(object source, + DirectoryExceptionEventArgs objDirectoryExceptionEventArgs); + + protected EventsGenerator m_objEventsGenerator = null; + + protected void StartEventPolling( + LdapMessageQueue queue, + LdapConnection conn, + int msgid) + { + // validate the argument values + if ( (queue == null) + || (conn == null)) + { + throw new ArgumentException("No parameter can be Null."); + } + + if (null == m_objEventsGenerator) + { + m_objEventsGenerator = new EventsGenerator(this, queue, conn, msgid); + m_objEventsGenerator.SleepTime = sleep_interval; + + m_objEventsGenerator.StartEventPolling(); + } + } // end of method StartEventPolling + + protected void StopEventPolling() + { + if (null != m_objEventsGenerator) + { + m_objEventsGenerator.StopEventPolling(); + m_objEventsGenerator = null; + } + } // end of method StopEventPolling + + protected abstract bool + NotifyEventListeners(LdapMessage sourceMessage, + EventClassifiers aClassification, + int nType); + + protected void NotifyListeners(LdapMessage sourceMessage, + EventClassifiers aClassification, + int nType) + { + // first let the actual source Notify the listeners with + // appropriate EventArgs + + bool bListenersNotified = NotifyEventListeners(sourceMessage, + aClassification, + nType); + + if (!bListenersNotified) + { + // Actual EventSource could not recognize the event + // Just notify the listeners for generic directory events + NotifyDirectoryListeners(sourceMessage, aClassification); + } + } + + protected void NotifyDirectoryListeners(LdapMessage sourceMessage, + EventClassifiers aClassification) + { + NotifyDirectoryListeners(new DirectoryEventArgs(sourceMessage, + aClassification)); + } + + protected void NotifyDirectoryListeners(DirectoryEventArgs objDirectoryEventArgs) + { + if (null != directory_event) + { + directory_event(this, objDirectoryEventArgs); + } + } + + protected void NotifyExceptionListeners(LdapMessage sourceMessage, LdapException ldapException) + { + if (null != directory_exception_event) + { + directory_exception_event(this, new DirectoryExceptionEventArgs(sourceMessage, ldapException)); + } + } + + + /// <summary> This is a nested class that is supposed to monitor + /// LdapMessageQueue for events generated by the LDAP Server. + /// + /// </summary> + protected class EventsGenerator + { + private LdapEventSource m_objLdapEventSource; + private LdapMessageQueue searchqueue; + private int messageid; + private LdapConnection ldapconnection; + private volatile bool isrunning = true; + + private int sleep_time; + /// <summary> + /// SleepTime controls the duration after which event polling is repeated. + /// </summary> + public int SleepTime + { + get + { + return sleep_time; + } + set + { + sleep_time = value; + } + } + + + public EventsGenerator(LdapEventSource objEventSource, + LdapMessageQueue queue, + LdapConnection conn, + int msgid) + { + m_objLdapEventSource = objEventSource; + searchqueue = queue; + ldapconnection = conn; + messageid = msgid; + sleep_time = DEFAULT_SLEEP_TIME; + } // end of Constructor + + protected void Run() + { + while (isrunning) + { + LdapMessage response = null; + try + { + while ((isrunning) + && (!searchqueue.isResponseReceived(messageid))) + { + try + { + Thread.Sleep(sleep_time); + } + catch (ThreadInterruptedException e) + { + Console.WriteLine("EventsGenerator::Run Got ThreadInterruptedException e = {0}", e); + } + } + + if (isrunning) + { + response = searchqueue.getResponse(messageid); + } + + if (response != null) + { + processmessage(response); + } + } + catch (LdapException e) + { + m_objLdapEventSource.NotifyExceptionListeners(response, e); + } + } + } // end of method run + + protected void processmessage(LdapMessage response) + { + if (response is LdapResponse) + { + try + { + ((LdapResponse) response).chkResultCode(); + + m_objLdapEventSource.NotifyEventListeners(response, + EventClassifiers.CLASSIFICATION_UNKNOWN, + EVENT_TYPE_UNKNOWN); + } + catch (LdapException e) + { + m_objLdapEventSource.NotifyExceptionListeners(response, e); + } + } + else + { + m_objLdapEventSource.NotifyEventListeners(response, + EventClassifiers.CLASSIFICATION_UNKNOWN, + EVENT_TYPE_UNKNOWN); + } + } // end of method processmessage + + public void StartEventPolling() + { + isrunning = true; + new Thread( new ThreadStart( Run ) ).Start(); + } + + public void StopEventPolling() + { + isrunning = false; + } // end of method stopEventGeneration + } // end of class EventsGenerator + + } // end of class LdapEventSource + +} // end of namespace diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Entries b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Entries new file mode 100644 index 00000000000..af720e1b0fb --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Entries @@ -0,0 +1,8 @@ +D/Novell.Directory.Ldap.Events.Edir.EventData//// +/EdirEventArgs.cs/1.1/Tue Sep 14 10:58:18 2004// +/EdirEventConstants.cs/1.1/Tue Sep 14 11:00:15 2004// +/EdirEventIntermediateResponse.cs/1.1/Tue Sep 14 11:00:50 2004// +/EdirEventSource.cs/1.1/Tue Sep 14 11:01:15 2004// +/EdirEventSpecifier.cs/1.1/Tue Sep 14 11:01:41 2004// +/MonitorEventRequest.cs/1.1/Tue Sep 14 11:02:14 2004// +/MonitorEventResponse.cs/1.1/Tue Sep 14 11:02:37 2004// diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Repository b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Repository new file mode 100644 index 00000000000..da896a344d1 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Repository @@ -0,0 +1 @@ +CsharpLDAP/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Root b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Root new file mode 100644 index 00000000000..a7e63c62413 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/CVS/Root @@ -0,0 +1 @@ +:ext:banil@forgecvs1.novell.com:/cvsroot/ldapcsharp diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventArgs.cs new file mode 100644 index 00000000000..2eaaddfc1e1 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventArgs.cs @@ -0,0 +1,64 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EdirEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This class represents the EventArgs for Edir events in general. + /// </summary> + public class EdirEventArgs : DirectoryEventArgs + { + /// <summary> + /// This property gives the contained event information in the form + /// of an IntermediateResponse if the contained information is of correct + /// type. In case the type of contained information is incorrect, null is returned. + /// </summary> + public EdirEventIntermediateResponse IntermediateResponse + { + get + { + if (ldap_message is EdirEventIntermediateResponse) + return (EdirEventIntermediateResponse)ldap_message; + else + return null; + } + } + + public EdirEventArgs(LdapMessage sourceMessage, + EventClassifiers aClassification) + : base(sourceMessage, aClassification) + { + } + + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventConstants.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventConstants.cs new file mode 100644 index 00000000000..cf07aabe0a7 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventConstants.cs @@ -0,0 +1,332 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EdirEventConstants.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// Enumeration for types of Edir event data + /// </summary> + public enum EdirEventDataType + { + EDIR_TAG_ENTRY_EVENT_DATA = 1, + EDIR_TAG_VALUE_EVENT_DATA, + EDIR_TAG_GENERAL_EVENT_DATA, + EDIR_TAG_SKULK_DATA, + EDIR_TAG_BINDERY_EVENT_DATA, + EDIR_TAG_DSESEV_INFO, + EDIR_TAG_MODULE_STATE_DATA, + EDIR_TAG_NETWORK_ADDRESS, + EDIR_TAG_CONNECTION_STATE, + EDIR_TAG_CHANGE_SERVER_ADDRESS, + EDIR_TAG_CHANGE_CONFIG_PARAM, + EDIR_TAG_NO_DATA, + EDIR_TAG_STATUS_LOG, + EDIR_TAG_DEBUG_EVENT_DATA + } + + /// <summary> + /// Enumeration for types of Edir event results + /// </summary> + public enum EdirEventResultType + { + EVT_STATUS_ALL, + EVT_STATUS_SUCCESS, + EVT_STATUS_FAILURE + } + + /// <summary> + /// Enumeration for types of Edir events + /// </summary> + public enum EdirEventType + { + EVT_INVALID = 0, + EVT_CREATE_ENTRY = 1, + EVT_DELETE_ENTRY = 2, + EVT_RENAME_ENTRY = 3, + EVT_MOVE_SOURCE_ENTRY = 4, + EVT_ADD_VALUE = 5, + EVT_DELETE_VALUE = 6, + EVT_CLOSE_STREAM = 7, + EVT_DELETE_ATTRIBUTE = 8, + EVT_SET_BINDERY_CONTEXT = 9, + EVT_CREATE_BINDERY_OBJECT = 10, + EVT_DELETE_BINDERY_OBJECT = 11, + EVT_CHECK_SEV = 12, + EVT_UPDATE_SEV = 13, + EVT_MOVE_DEST_ENTRY = 14, + EVT_DELETE_UNUSED_EXTREF = 15, + EVT_REMOTE_SERVER_DOWN = 17, + EVT_NCP_RETRY_EXPENDED = 18, + EVT_PARTITION_OPERATION_EVENT = 20, + EVT_CHANGE_MODULE_STATE = 21, + EVT_DB_AUTHEN = 26, + EVT_DB_BACKLINK = 27, + EVT_DB_BUFFERS = 28, + EVT_DB_COLL = 29, + EVT_DB_DSAGENT = 30, + EVT_DB_EMU = 31, + EVT_DB_FRAGGER = 32, + EVT_DB_INIT = 33, + EVT_DB_INSPECTOR = 34, + EVT_DB_JANITOR = 35, + EVT_DB_LIMBER = 36, + EVT_DB_LOCKING = 37, + EVT_DB_MOVE = 38, + EVT_DB_MIN = 39, + EVT_DB_MISC = 40, + EVT_DB_PART = 41, + EVT_DB_RECMAN = 42, + EVT_DB_RESNAME = 44, + EVT_DB_SAP = 45, + EVT_DB_SCHEMA = 46, + EVT_DB_SKULKER = 47, + EVT_DB_STREAMS = 48, + EVT_DB_SYNC_IN = 49, + EVT_DB_THREADS = 50, + EVT_DB_TIMEVECTOR = 51, + EVT_DB_VCLIENT = 52, + EVT_AGENT_OPEN_LOCAL = 53, + EVT_AGENT_CLOSE_LOCAL = 54, + EVT_DS_ERR_VIA_BINDERY = 55, + EVT_DSA_BAD_VERB = 56, + EVT_DSA_REQUEST_START = 57, + EVT_DSA_REQUEST_END = 58, + EVT_MOVE_SUBTREE = 59, + EVT_NO_REPLICA_PTR = 60, + EVT_SYNC_IN_END = 61, + EVT_BKLINK_SEV = 62, + EVT_BKLINK_OPERATOR = 63, + EVT_DELETE_SUBTREE = 64, + EVT_REFERRAL = 67, + EVT_UPDATE_CLASS_DEF = 68, + EVT_UPDATE_ATTR_DEF = 69, + EVT_LOST_ENTRY = 70, + EVT_PURGE_ENTRY_FAIL = 71, + EVT_PURGE_START = 72, + EVT_PURGE_END = 73, + EVT_LIMBER_DONE = 76, + EVT_SPLIT_DONE = 77, + EVT_SYNC_SVR_OUT_START = 78, + EVT_SYNC_SVR_OUT_END = 79, + EVT_SYNC_PART_START = 80, + EVT_SYNC_PART_END = 81, + EVT_MOVE_TREE_START = 82, + EVT_MOVE_TREE_END = 83, + EVT_JOIN_DONE = 86, + EVT_PARTITION_LOCKED = 87, + EVT_PARTITION_UNLOCKED = 88, + EVT_SCHEMA_SYNC = 89, + EVT_NAME_COLLISION = 90, + EVT_NLM_LOADED = 91, + EVT_LUMBER_DONE = 94, + EVT_BACKLINK_PROC_DONE = 95, + EVT_SERVER_RENAME = 96, + EVT_SYNTHETIC_TIME = 97, + EVT_SERVER_ADDRESS_CHANGE = 98, + EVT_DSA_READ = 99, + EVT_LOGIN = 100, + EVT_CHGPASS = 101, + EVT_LOGOUT = 102, + EVT_ADD_REPLICA = 103, + EVT_REMOVE_REPLICA = 104, + EVT_SPLIT_PARTITION = 105, + EVT_JOIN_PARTITIONS = 106, + EVT_CHANGE_REPLICA_TYPE = 107, + EVT_REMOVE_ENTRY = 108, + EVT_ABORT_PARTITION_OP = 109, + EVT_RECV_REPLICA_UPDATES = 110, + EVT_REPAIR_TIME_STAMPS = 111, + EVT_SEND_REPLICA_UPDATES = 112, + EVT_VERIFY_PASS = 113, + EVT_BACKUP_ENTRY = 114, + EVT_RESTORE_ENTRY = 115, + EVT_DEFINE_ATTR_DEF = 116, + EVT_REMOVE_ATTR_DEF = 117, + EVT_REMOVE_CLASS_DEF = 118, + EVT_DEFINE_CLASS_DEF = 119, + EVT_MODIFY_CLASS_DEF = 120, + EVT_RESET_DS_COUNTERS = 121, + EVT_REMOVE_ENTRY_DIR = 122, + EVT_COMPARE_ATTR_VALUE = 123, + EVT_STREAM = 124, + EVT_LIST_SUBORDINATES = 125, + EVT_LIST_CONT_CLASSES = 126, + EVT_INSPECT_ENTRY = 127, + EVT_RESEND_ENTRY = 128, + EVT_MUTATE_ENTRY = 129, + EVT_MERGE_ENTRIES = 130, + EVT_MERGE_TREE = 131, + EVT_CREATE_SUBREF = 132, + EVT_LIST_PARTITIONS = 133, + EVT_READ_ATTR = 134, + EVT_READ_REFERENCES = 135, + EVT_UPDATE_REPLICA = 136, + EVT_START_UPDATE_REPLICA = 137, + EVT_END_UPDATE_REPLICA = 138, + EVT_SYNC_PARTITION = 139, + EVT_SYNC_SCHEMA = 140, + EVT_CREATE_BACKLINK = 141, + EVT_CHECK_CONSOLE_OPERATOR = 142, + EVT_CHANGE_TREE_NAME = 143, + EVT_START_JOIN = 144, + EVT_ABORT_JOIN = 145, + EVT_UPDATE_SCHEMA = 146, + EVT_START_UPDATE_SCHEMA = 147, + EVT_END_UPDATE_SCHEMA = 148, + EVT_MOVE_TREE = 149, + EVT_RELOAD_DS = 150, + EVT_ADD_PROPERTY = 151, + EVT_DELETE_PROPERTY = 152, + EVT_ADD_MEMBER = 153, + EVT_DELETE_MEMBER = 154, + EVT_CHANGE_PROP_SECURITY = 155, + EVT_CHANGE_OBJ_SECURITY = 156, + EVT_CONNECT_TO_ADDRESS = 158, + EVT_SEARCH = 159, + EVT_PARTITION_STATE_CHG = 160, + EVT_REMOVE_BACKLINK = 161, + EVT_LOW_LEVEL_JOIN = 162, + EVT_CREATE_NAMEBASE = 163, + EVT_CHANGE_SECURITY_EQUALS = 164, + EVT_DB_NCPENG = 166, + EVT_CRC_FAILURE = 167, + EVT_ADD_ENTRY = 168, + EVT_MODIFY_ENTRY = 169, + EVT_OPEN_BINDERY = 171, + EVT_CLOSE_BINDERY = 172, + EVT_CHANGE_CONN_STATE = 173, + EVT_NEW_SCHEMA_EPOCH = 174, + EVT_DB_AUDIT = 175, + EVT_DB_AUDIT_NCP = 176, + EVT_DB_AUDIT_SKULK = 177, + EVT_MODIFY_RDN = 178, + EVT_ENTRYID_SWAP = 181, + EVT_INSIDE_NCP_REQUEST = 182, + EVT_DB_LOST_ENTRY = 183, + EVT_DB_CHANGE_CACHE = 184, + EVT_LOW_LEVEL_SPLIT = 185, + EVT_DB_PURGE = 186, + EVT_END_NAMEBASE_TRANSACTION = 187, + EVT_ALLOW_LOGIN = 188, + EVT_DB_CLIENT_BUFFERS = 189, + EVT_DB_WANMAN = 190, + EVT_LOCAL_REPLICA_CHANGE = 197, + EVT_DB_DRL = 198, + EVT_MOVE_ENTRY_SOURCE = 199, + EVT_MOVE_ENTRY_DEST = 200, + EVT_NOTIFY_REF_CHANGE = 201, + EVT_DB_ALLOC = 202, + EVT_CONSOLE_OPERATION = 203, + EVT_DB_SERVER_PACKET = 204, + EVT_DB_OBIT = 207, + EVT_REPLICA_IN_TRANSITION = 208, + EVT_DB_SYNC_DETAIL = 209, + EVT_DB_CONN_TRACE = 210, + /* + EVT_CHANGE_CONFIG_PARM = 211, + EVT_COMPUTE_CONN_SEV_INLINE = 212, + */ + EVT_BEGIN_NAMEBASE_TRANSACTION = 213, + EVT_DB_DIRXML = 214, + EVT_VR_DRIVER_STATE_CHANGE = 215, + EVT_REQ_UPDATE_SERVER_STATUS = 216, + EVT_DB_DIRXML_DRIVERS = 217, + EVT_DB_NDSMON = 218, + EVT_CHANGE_SERVER_ADDRS = 219, + EVT_DB_DNS = 220, + EVT_DB_REPAIR = 221, + EVT_DB_REPAIR_DEBUG = 222, + EVT_ITERATOR = 224, + EVT_DB_SCHEMA_DETAIL = 225, + EVT_LOW_LEVEL_JOIN_BEGIN = 226, + EVT_DB_IN_SYNC_DETAIL = 227, + EVT_PRE_DELETE_ENTRY = 228, + EVT_DB_SSL = 229, + EVT_DB_PKI = 230, + EVT_DB_HTTPSTK = 231, + EVT_DB_LDAPSTK = 232, + EVT_DB_NICIEXT = 233, + EVT_DB_SECRET_STORE = 234, + EVT_DB_NMAS = 235, + EVT_DB_BACKLINK_DETAIL = 236, + EVT_DB_DRL_DETAIL = 237, + EVT_DB_OBJECT_PRODUCER = 238, + EVT_DB_SEARCH = 239, + EVT_DB_SEARCH_DETAIL = 240, + EVT_STATUS_LOG = 241, + EVT_DB_NPKI_API = 242, + EVT_MAX_EVENTS + } + + /// <summary> + /// Enumeration for types of Edir event Debug parameters + /// </summary> + public enum DebugParameterType + { + ENTRYID = 1, + STRING, + BINARY, + INTEGER, + ADDRESS, + TIMESTAMP, + TIMEVECTOR + } + + /// <summary> + /// Enumeration for fields of Edir General event + /// </summary> + public enum GeneralEventField + { + EVT_TAG_GEN_DSTIME = 1, + EVT_TAG_GEN_MILLISEC, + EVT_TAG_GEN_VERB, + EVT_TAG_GEN_CURRPROC, + EVT_TAG_GEN_PERP, + EVT_TAG_GEN_INTEGERS, + EVT_TAG_GEN_STRINGS + } + + public class EventOids + { + /* Oid for requests */ + public const string NLDAP_MONITOR_EVENTS_REQUEST = + "2.16.840.1.113719.1.27.100.79"; + + public const string NLDAP_MONITOR_EVENTS_RESPONSE = + "2.16.840.1.113719.1.27.100.80"; + + public const string NLDAP_EVENT_NOTIFICATION = + "2.16.840.1.113719.1.27.100.81"; + + public const string NLDAP_FILTERED_MONITOR_EVENTS_REQUEST = + "2.16.840.1.113719.1.27.100.84"; + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventIntermediateResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventIntermediateResponse.cs new file mode 100644 index 00000000000..c811f51f0ff --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventIntermediateResponse.cs @@ -0,0 +1,187 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EdirEventIntermediateResponse.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; +using System.IO; + +using Novell.Directory.Ldap; +using Novell.Directory.Ldap.Rfc2251; +using Novell.Directory.Ldap.Asn1; +using Novell.Directory.Ldap.Events.Edir.EventData; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This class represents the intermediate response corresponding to edir events. + /// </summary> + public class EdirEventIntermediateResponse : LdapIntermediateResponse + { + protected EdirEventType event_type; + + /// <summary> + /// Type of Edir event. + /// </summary> + public EdirEventType EventType + { + get + { + return event_type; + } + } + + protected EdirEventResultType event_result_type; + + /// <summary> + /// Type of Edir event result. + /// </summary> + public EdirEventResultType EventResultType + { + get + { + return event_result_type; + } + } + + protected BaseEdirEventData event_response_data; + + /// <summary> + /// The response data object associated with Edir event. + /// </summary> + public BaseEdirEventData EventResponseDataObject + { + get + { + return event_response_data; + } + } + + public EdirEventIntermediateResponse(RfcLdapMessage message) + : base(message) + { + ProcessMessage(getValue()); + } + + public EdirEventIntermediateResponse(byte[] message) + : base( new RfcLdapMessage( new Asn1Sequence() ) ) + { + ProcessMessage(SupportClass.ToSByteArray(message)); + } + + [CLSCompliantAttribute(false)] + protected void ProcessMessage(sbyte[] returnedValue) + { + LBERDecoder decoder = new LBERDecoder(); + Asn1Sequence sequence = (Asn1Sequence) decoder.decode(returnedValue); + + event_type = (EdirEventType)(((Asn1Integer) sequence.get_Renamed(0)).intValue()); + event_result_type = (EdirEventResultType)(((Asn1Integer) sequence.get_Renamed(1)).intValue()); + + if (sequence.size() > 2) + { + Asn1Tagged objTagged = (Asn1Tagged) sequence.get_Renamed(2); + + switch((EdirEventDataType)(objTagged.getIdentifier().Tag)) + { + case EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA: + event_response_data = new EntryEventData(EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA: + event_response_data = new ValueEventData(EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA: + event_response_data = new DebugEventData(EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA: + event_response_data = new GeneralDSEventData(EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_SKULK_DATA: + event_response_data = null; + break; + + case EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA: + event_response_data = new BinderyObjectEventData(EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_DSESEV_INFO: + event_response_data = new SecurityEquivalenceEventData(EdirEventDataType.EDIR_TAG_DSESEV_INFO, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA: + event_response_data = new ModuleStateEventData(EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS: + event_response_data = new NetworkAddressEventData(EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_CONNECTION_STATE: + event_response_data = new ConnectionStateEventData(EdirEventDataType.EDIR_TAG_CONNECTION_STATE, objTagged.taggedValue()); + break; + + case EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS: + event_response_data = new ChangeAddressEventData(EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS, objTagged.taggedValue()); + break; + + /* + case EdirEventDataType.EDIR_TAG_CHANGE_CONFIG_PARAM : + responsedata = + new ChangeConfigEventData( + taggedobject.taggedValue()); + + break; + + case EdirEventDataType.EDIR_TAG_STATUS_LOG : + responsedata = + new StatusLogEventData(taggedobject.taggedValue()); + + break; + */ + case EdirEventDataType.EDIR_TAG_NO_DATA: + event_response_data = null; + break; + + default: + //unhandled data. + throw new IOException(); + } + } else + { + //NO DATA + event_response_data = null; + } + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSource.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSource.cs new file mode 100644 index 00000000000..1880b429fd9 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSource.cs @@ -0,0 +1,139 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EdirEventSource.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This is the source class for Edir events. + /// </summary> + public class EdirEventSource : LdapEventSource + { + protected EdirEventHandler edir_event; + + /// <summary> + /// Caller has to register with this event in order to be notified of + /// corresponding Edir events. + /// </summary> + public event EdirEventHandler EdirEvent + { + add + { + edir_event += value; + ListenerAdded(); + } + remove + { + edir_event -= value; + ListenerRemoved(); + } + } + + /// <summary> + /// EdirEventHandler is the delegate definition for EdirEvent. + /// The client (listener) has to register using this delegate in order to + /// get corresponding Edir events. + /// </summary> + public delegate + void EdirEventHandler(object source, + EdirEventArgs objEdirEventArgs); + + protected override int GetListeners() + { + int nListeners = 0; + if (null != edir_event) + nListeners = edir_event.GetInvocationList().Length; + + return nListeners; + } + + protected LdapConnection mConnection; + protected MonitorEventRequest mRequestOperation = null; + protected LdapResponseQueue mQueue = null; + + public EdirEventSource(EdirEventSpecifier[] specifier, LdapConnection conn) + { + if ((null == specifier) || (null == conn)) + throw new ArgumentException("Null argument specified"); + + mRequestOperation = new MonitorEventRequest(specifier); + mConnection = conn; + } + + protected override void StartSearchAndPolling() + { + mQueue = mConnection.ExtendedOperation(mRequestOperation, null, null); + int[] ids = mQueue.MessageIDs; + + if (ids.Length != 1) + { + throw new LdapException( + null, + LdapException.LOCAL_ERROR, + "Unable to Obtain Message Id" + ); + } + + StartEventPolling(mQueue, mConnection, ids[0]); + } + + protected override void StopSearchAndPolling() + { + mConnection.Abandon(mQueue); + StopEventPolling(); + } + + protected override bool NotifyEventListeners(LdapMessage sourceMessage, + EventClassifiers aClassification, + int nType) + { + bool bListenersNotified = false; + if (null != edir_event) + { + if (null != sourceMessage) + { + if ((sourceMessage.Type == LdapMessage.INTERMEDIATE_RESPONSE) && + (sourceMessage is EdirEventIntermediateResponse)) + { + edir_event(this, + new EdirEventArgs(sourceMessage, + EventClassifiers.CLASSIFICATION_EDIR_EVENT)); + bListenersNotified = true; + } + } + } + + return bListenersNotified; + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSpecifier.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSpecifier.cs new file mode 100644 index 00000000000..2a34301ae90 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSpecifier.cs @@ -0,0 +1,79 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EdirEventSpecifier.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This class denotes the mechanism to specify the event of interest. + /// </summary> + public class EdirEventSpecifier + { + private EdirEventType event_type; + public EdirEventType EventType + { + get + { + return event_type; + } + } + + private EdirEventResultType event_result_type; + public EdirEventResultType EventResultType + { + get + { + return event_result_type; + } + } + + private string event_filter; + public string EventFilter + { + get + { + return event_filter; + } + } + + public EdirEventSpecifier(EdirEventType eventType, EdirEventResultType eventResultType) : + this(eventType, eventResultType, null) + { + } + + public EdirEventSpecifier(EdirEventType eventType, EdirEventResultType eventResultType, string filter) + { + event_type = eventType; + event_result_type = eventResultType; + event_filter = filter; + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventRequest.cs new file mode 100644 index 00000000000..236f3e32afa --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventRequest.cs @@ -0,0 +1,143 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.MonitorEventRequest.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; +using System.IO; + +using Novell.Directory.Ldap.Utilclass; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This class denotes the mechanism to specify the event of interest. + /// </summary> + public class MonitorEventRequest : LdapExtendedOperation + { + static MonitorEventRequest() + { + /* + * Register the extendedresponse class which is returned by the + * server in response to a MonitorEventRequest + */ + try + { + LdapExtendedResponse.register(EventOids.NLDAP_MONITOR_EVENTS_RESPONSE, + Type.GetType("Novell.Directory.Ldap.Events.Edir.MonitorEventResponse", true)); + } + catch(TypeLoadException e) + { + // TODO: put something in the Debug... + } + catch(Exception e) + { + // TODO: put something in the Debug... + } + + //Also try to register EdirEventIntermediateResponse + try + { + LdapIntermediateResponse.register(EventOids.NLDAP_EVENT_NOTIFICATION, + Type.GetType("Novell.Directory.Ldap.Events.Edir.EdirEventIntermediateResponse", true)); + } + catch(TypeLoadException e) + { + // TODO: put something in the Debug... + } + catch(Exception e) + { + // TODO: put something in the Debug... + } + } // end of static constructor + + public MonitorEventRequest(EdirEventSpecifier[] specifiers) : + base(EventOids.NLDAP_MONITOR_EVENTS_REQUEST, null) + { + if ((specifiers == null)) + { + throw new ArgumentException(ExceptionMessages.PARAM_ERROR); + } + + MemoryStream encodedData = new MemoryStream(); + LBEREncoder encoder = new LBEREncoder(); + + Asn1Sequence asnSequence = new Asn1Sequence(); + try + { + asnSequence.add(new Asn1Integer(specifiers.Length)); + + Asn1Set asnSet = new Asn1Set(); + bool bFiltered = false; + for (int nIndex = 0; nIndex < specifiers.Length; nIndex++) + { + Asn1Sequence specifierSequence = new Asn1Sequence(); + specifierSequence.add(new Asn1Integer((int)(specifiers[nIndex].EventType))); + specifierSequence.add(new Asn1Enumerated((int)(specifiers[nIndex].EventResultType))); + if (0 == nIndex) + { + bFiltered = (null != specifiers[nIndex].EventFilter); + if (bFiltered) + setID(EventOids.NLDAP_FILTERED_MONITOR_EVENTS_REQUEST); + } + + if (bFiltered) + { + // A filter is expected + if (null == specifiers[nIndex].EventFilter) + throw new ArgumentException("Filter cannot be null,for Filter events"); + + specifierSequence.add(new Asn1OctetString(specifiers[nIndex].EventFilter)); + } + else + { + // No filter is expected + if (null != specifiers[nIndex].EventFilter) + throw new ArgumentException("Filter cannot be specified for non Filter events"); + } + + asnSet.add(specifierSequence); + } + + asnSequence.add(asnSet); + asnSequence.encode(encoder, encodedData); + } + catch(Exception e) + { + throw new LdapException(ExceptionMessages.ENCODING_ERROR, + LdapException.ENCODING_ERROR, + null); + } + + setValue(SupportClass.ToSByteArray(encodedData.ToArray())); + } // end of the constructor MonitorEventRequest + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventResponse.cs new file mode 100644 index 00000000000..5fba1cf0638 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventResponse.cs @@ -0,0 +1,86 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.MonitorEventResponse.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using Novell.Directory.Ldap.Rfc2251; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// This object represents the ExtendedResponse returned when Event + /// Registeration fails. This Extended Response structure is generated for + /// requests send as MonitorEventRequest. + /// </summary> + public class MonitorEventResponse : LdapExtendedResponse + { + protected EdirEventSpecifier[] specifier_list; + public EdirEventSpecifier[] SpecifierList + { + get + { + return specifier_list; + } + } + + public MonitorEventResponse(RfcLdapMessage message) + : base(message) + { + sbyte[] returnedValue = Value; + + if (null == returnedValue) + { + throw new LdapException(LdapException.resultCodeToString(ResultCode), + ResultCode, + null); + } + + LBERDecoder decoder = new LBERDecoder(); + + Asn1Sequence sequence = (Asn1Sequence) decoder.decode(returnedValue); + + int length = ((Asn1Integer) sequence.get_Renamed(0)).intValue(); + Asn1Set sequenceSet = (Asn1Set) sequence.get_Renamed(1); + specifier_list = new EdirEventSpecifier[length]; + + for (int i = 0; i < length; i++) + { + Asn1Sequence eventspecifiersequence = + (Asn1Sequence) sequenceSet.get_Renamed(i); + int classfication = + ((Asn1Integer) eventspecifiersequence.get_Renamed(0)).intValue(); + int enumtype = + ((Asn1Enumerated) eventspecifiersequence.get_Renamed(1)).intValue(); + specifier_list[i] = + new EdirEventSpecifier((EdirEventType)classfication, (EdirEventResultType)enumtype); + } + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BaseEdirEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BaseEdirEventData.cs new file mode 100644 index 00000000000..86b089db33c --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BaseEdirEventData.cs @@ -0,0 +1,77 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.BaseEdirEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.IO; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This is the base class for all types of data classes associated + /// with an event. + /// </summary> + public class BaseEdirEventData + { + protected MemoryStream decodedData = null; + protected LBERDecoder decoder = null; + + protected EdirEventDataType event_data_type; + + /// <summary> + /// The value for this attribute allows the caller to identify the + /// type of the data object. + /// </summary> + public EdirEventDataType EventDataType + { + get + { + return event_data_type; + } + } + + public BaseEdirEventData(EdirEventDataType eventDataType, Asn1Object message) + { + event_data_type = eventDataType; + + byte[] byteData = SupportClass.ToByteArray(((Asn1OctetString) message).byteValue()); + decodedData = new MemoryStream(byteData); + decoder = new LBERDecoder(); + } + + protected void DataInitDone() + { + // We dont want the unnecessary memory to remain occupied if + // this object is retained by the caller + decodedData = null; + decoder = null; + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BinderyObjectEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BinderyObjectEventData.cs new file mode 100644 index 00000000000..4aa6a568914 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BinderyObjectEventData.cs @@ -0,0 +1,119 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.BinderyObjectEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Bindery Events. + /// </summary> + public class BinderyObjectEventData : BaseEdirEventData + { + protected string strEntryDN; + public string EntryDN + { + get + { + return strEntryDN; + } + } + + protected int nType; + public int ValueType + { + get + { + return nType; + } + } + + protected int nEmuObjFlags; + public int EmuObjFlags + { + get + { + return nEmuObjFlags; + } + } + + protected int nSecurity; + public int Security + { + get + { + return nSecurity; + } + } + + protected string strName; + public string Name + { + get + { + return strName; + } + } + + public BinderyObjectEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + strEntryDN = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + nType = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + nEmuObjFlags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + nSecurity = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strName = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[BinderyObjectEvent"); + buf.AppendFormat("(EntryDn={0})", strEntryDN); + buf.AppendFormat("(Type={0})", nType); + buf.AppendFormat("(EnumOldFlags={0})", nEmuObjFlags); + buf.AppendFormat("(Secuirty={0})", nSecurity); + buf.AppendFormat("(Name={0})", strName); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Entries b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Entries new file mode 100644 index 00000000000..d4172cae32c --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Entries @@ -0,0 +1,15 @@ +/BaseEdirEventData.cs/1.1/Tue Sep 14 11:05:49 2004// +/BinderyObjectEventData.cs/1.1/Tue Sep 14 11:06:27 2004// +/ChangeAddressEventData.cs/1.1/Tue Sep 14 11:06:52 2004// +/ConnectionStateEventData.cs/1.1/Tue Sep 14 11:07:20 2004// +/DSETimeStamp.cs/1.1/Tue Sep 14 11:08:54 2004// +/DebugEventData.cs/1.1/Tue Sep 14 11:08:00 2004// +/DebugParameter.cs/1.1/Tue Sep 14 11:08:33 2004// +/EntryEventData.cs/1.1/Tue Sep 14 11:09:18 2004// +/GeneralDSEventData.cs/1.1/Tue Sep 14 11:09:42 2004// +/ModuleStateEventData.cs/1.1/Tue Sep 14 11:10:11 2004// +/NetworkAddressEventData.cs/1.1/Tue Sep 14 11:10:36 2004// +/ReferralAddress.cs/1.1/Tue Sep 14 11:11:01 2004// +/SecurityEquivalenceEventData.cs/1.1/Wed Sep 15 10:50:28 2004// +/ValueEventData.cs/1.1/Tue Sep 14 11:12:01 2004// +D diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Repository b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Repository new file mode 100644 index 00000000000..57e35679a8c --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Repository @@ -0,0 +1 @@ +CsharpLDAP/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Root b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Root new file mode 100644 index 00000000000..a7e63c62413 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/CVS/Root @@ -0,0 +1 @@ +:ext:banil@forgecvs1.novell.com:/cvsroot/ldapcsharp diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ChangeAddressEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ChangeAddressEventData.cs new file mode 100644 index 00000000000..5d3055312c0 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ChangeAddressEventData.cs @@ -0,0 +1,130 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.ChangeAddressEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Change Address. + /// </summary> + public class ChangeAddressEventData : BaseEdirEventData + { + protected int nFlags; + public int Flags + { + get + { + return nFlags; + } + } + + protected int nProto; + public int Proto + { + get + { + return nProto; + } + } + + protected int address_family; + public int AddressFamily + { + get + { + return address_family; + } + } + + protected string strAddress; + public string Address + { + get + { + return strAddress; + } + } + + protected string pstk_name; + public string PstkName + { + get + { + return pstk_name; + } + } + + protected string source_module; + public string SourceModule + { + get + { + return source_module; + } + } + + public ChangeAddressEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + nFlags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + nProto = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + address_family = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strAddress = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + pstk_name = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + source_module = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[ChangeAddresssEvent"); + buf.AppendFormat("(flags={0})", + nFlags); + buf.AppendFormat("(proto={0})", nProto); + buf.AppendFormat("(addrFamily={0})", address_family); + buf.AppendFormat("(address={0})", strAddress); + buf.AppendFormat("(pstkName={0})", pstk_name); + buf.AppendFormat("(source={0})", source_module); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ConnectionStateEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ConnectionStateEventData.cs new file mode 100644 index 00000000000..25f08fec627 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ConnectionStateEventData.cs @@ -0,0 +1,108 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.ConnectionStateEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Connection State Events. + /// </summary> + public class ConnectionStateEventData : BaseEdirEventData + { + protected string strConnectionDN; + public string ConnectionDN + { + get + { + return strConnectionDN; + } + } + + protected int old_flags; + public int OldFlags + { + get + { + return old_flags; + } + } + + protected int new_flags; + public int NewFlags + { + get + { + return new_flags; + } + } + + protected string source_module; + public string SourceModule + { + get + { + return source_module; + } + } + + public ConnectionStateEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + strConnectionDN = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + old_flags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + new_flags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + source_module = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[ConnectionStateEvent"); + buf.AppendFormat("(ConnectionDN={0})", strConnectionDN); + buf.AppendFormat("(oldFlags={0})", old_flags); + buf.AppendFormat("(newFlags={0})", new_flags); + buf.AppendFormat("(SourceModule={0})", source_module); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DSETimeStamp.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DSETimeStamp.cs new file mode 100644 index 00000000000..be28e9e76b5 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DSETimeStamp.cs @@ -0,0 +1,93 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.DSETimeStamp.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir +{ + /// <summary> + /// The class represents the Timestamp datastructure for Edir events + /// Notification. + /// </summary> + public class DSETimeStamp + { + protected int nSeconds; + public int Seconds + { + get + { + return nSeconds; + } + } + + protected int replica_number; + public int ReplicaNumber + { + get + { + return replica_number; + } + } + + protected int nEvent; + public int Event + { + get + { + return nEvent; + } + } + + public DSETimeStamp(Asn1Sequence dseObject) + { + nSeconds = ((Asn1Integer)dseObject.get_Renamed(0)).intValue(); + replica_number = ((Asn1Integer) dseObject.get_Renamed(1)).intValue(); + nEvent = ((Asn1Integer) dseObject.get_Renamed(2)).intValue(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + + buf.AppendFormat("[TimeStamp (seconds={0})", nSeconds); + buf.AppendFormat("(replicaNumber={0})", replica_number); + buf.AppendFormat("(event={0})", nEvent); + buf.Append("]"); + + return buf.ToString(); + } + } +} + diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugEventData.cs new file mode 100644 index 00000000000..1230bd15f8a --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugEventData.cs @@ -0,0 +1,161 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.DebugEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Collections; +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Debug Events. + /// </summary> + public class DebugEventData : BaseEdirEventData + { + protected int ds_time; + public int DSTime + { + get + { + return ds_time; + } + } + + protected int milli_seconds; + public int MilliSeconds + { + get + { + return milli_seconds; + } + } + + protected string strPerpetratorDN; + public string PerpetratorDN + { + get + { + return strPerpetratorDN; + } + } + + protected string strFormatString; + public string FormatString + { + get + { + return strFormatString; + } + } + + protected int nVerb; + public int Verb + { + get + { + return nVerb; + } + } + + protected int parameter_count; + public int ParameterCount + { + get + { + return parameter_count; + } + } + + protected ArrayList parameter_collection; + public ArrayList Parameters + { + get + { + return parameter_collection; + } + } + + public DebugEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + ds_time = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + milli_seconds = + ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + + strPerpetratorDN = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strFormatString = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + nVerb = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + parameter_count = + ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + + parameter_collection = new ArrayList(); + + if (parameter_count > 0) + { + Asn1Sequence seq = (Asn1Sequence) decoder.decode(decodedData, length); + for (int i = 0; i < parameter_count; i++) + { + parameter_collection.Add( + new DebugParameter((Asn1Tagged) seq.get_Renamed(i)) + ); + } + } + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[DebugEventData"); + buf.AppendFormat("(Millseconds={0})", milli_seconds); + buf.AppendFormat("(DSTime={0})", ds_time); + buf.AppendFormat("(PerpetratorDN={0})", strPerpetratorDN); + buf.AppendFormat("(Verb={0})",nVerb); + buf.AppendFormat("(ParameterCount={0})", parameter_count); + for (int i = 0; i < parameter_count; i++) + { + buf.AppendFormat("(Parameter[{0}]={1})", i, parameter_collection[i]); + } + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugParameter.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugParameter.cs new file mode 100644 index 00000000000..479976e3980 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugParameter.cs @@ -0,0 +1,159 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.DebugParameter.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; +using System.Collections; +using System.IO; +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the Debug Paramenter that is part of + /// the DebugEventData. + /// </summary> + public class DebugParameter + { + protected DebugParameterType debug_type; + public DebugParameterType DebugType + { + get + { + return debug_type; + } + } + + protected object objData; + public object Data + { + get + { + return objData; + } + } + + public DebugParameter(Asn1Tagged dseObject) + { + switch ((DebugParameterType)(dseObject.getIdentifier().Tag)) + { + case DebugParameterType.ENTRYID: + case DebugParameterType.INTEGER: + objData = getTaggedIntValue(dseObject); + break; + + case DebugParameterType.BINARY: + objData = ((Asn1OctetString) dseObject.taggedValue()).byteValue(); + break; + + case DebugParameterType.STRING: + objData = ((Asn1OctetString) dseObject.taggedValue()).stringValue(); + break; + + case DebugParameterType.TIMESTAMP: + objData = new DSETimeStamp(getTaggedSequence(dseObject)); + break; + + case DebugParameterType.TIMEVECTOR: + ArrayList timeVector = new ArrayList(); + Asn1Sequence seq = getTaggedSequence(dseObject); + int count = ((Asn1Integer) seq.get_Renamed(0)).intValue(); + if (count > 0) + { + Asn1Sequence timeSeq = (Asn1Sequence) seq.get_Renamed(1); + + for (int i = 0; i < count; i++) + { + timeVector.Add(new DSETimeStamp((Asn1Sequence) timeSeq.get_Renamed(i))); + } + } + + objData = timeVector; + break; + + case DebugParameterType.ADDRESS: + objData = new ReferralAddress(getTaggedSequence(dseObject)); + break; + + default: + throw new IOException("Unknown Tag in DebugParameter.."); + } + + debug_type = (DebugParameterType)(dseObject.getIdentifier().Tag); + } + + protected int getTaggedIntValue(Asn1Tagged tagVal) + { + Asn1Object obj = tagVal.taggedValue(); + byte[] dataBytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue()); + + MemoryStream decodedData = new MemoryStream(dataBytes); + LBERDecoder decoder = new LBERDecoder(); + + return ((int) decoder.decodeNumeric( + decodedData, + dataBytes.Length)); + } + + protected Asn1Sequence getTaggedSequence(Asn1Tagged tagVal) + { + Asn1Object obj = tagVal.taggedValue(); + byte[] dataBytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue()); + + MemoryStream decodedData = new MemoryStream(dataBytes); + LBERDecoder decoder = new LBERDecoder(); + + return new Asn1Sequence(decoder, decodedData, dataBytes.Length); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[DebugParameter"); + if (Enum.IsDefined(debug_type.GetType(), debug_type)) + { + buf.AppendFormat("(type={0},", debug_type); + buf.AppendFormat("value={0})", objData); + } + else + { + buf.Append("(type=Unknown)"); + } + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/EntryEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/EntryEventData.cs new file mode 100644 index 00000000000..dc0f259f5d2 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/EntryEventData.cs @@ -0,0 +1,146 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.EntryEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// The class represents the data for Entry Events. + /// </summary> + public class EntryEventData : BaseEdirEventData + { + protected string strPerpetratorDN; + public string PerpetratorDN + { + get + { + return strPerpetratorDN; + } + } + + protected string strEntry; + public string Entry + { + get + { + return strEntry; + } + } + + protected string strNewDN; + public string NewDN + { + get + { + return strNewDN; + } + } + + protected string strClassId; + public string ClassId + { + get + { + return strClassId; + } + } + + protected int nVerb; + public int Verb + { + get + { + return nVerb; + } + } + + protected int nFlags; + public int Flags + { + get + { + return nFlags; + } + } + + protected DSETimeStamp timeStampObj; + public DSETimeStamp TimeStamp + { + get + { + return timeStampObj; + } + } + + public EntryEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + strPerpetratorDN = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strEntry = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strClassId = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + timeStampObj = + new DSETimeStamp((Asn1Sequence) decoder.decode(decodedData, length)); + nVerb = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + nFlags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strNewDN = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("EntryEventData["); + buf.AppendFormat("(Entry={0})", strEntry); + buf.AppendFormat("(Prepetrator={0})", strPerpetratorDN); + buf.AppendFormat("(ClassId={0})", strClassId); + buf.AppendFormat("(Verb={0})", nVerb); + buf.AppendFormat("(Flags={0})", nFlags); + buf.AppendFormat("(NewDN={0})", strNewDN); + buf.AppendFormat("(TimeStamp={0})", timeStampObj); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/GeneralDSEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/GeneralDSEventData.cs new file mode 100644 index 00000000000..f81e88416c0 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/GeneralDSEventData.cs @@ -0,0 +1,254 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.GeneralDSEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.IO; +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// The class represents the data for General DS Events. + /// </summary> + public class GeneralDSEventData : BaseEdirEventData + { + protected int ds_time; + public int DSTime + { + get + { + return ds_time; + } + } + + protected int milli_seconds; + public int MilliSeconds + { + get + { + return milli_seconds; + } + } + + protected int nVerb; + public int Verb + { + get + { + return nVerb; + } + } + + protected int current_process; + public int CurrentProcess + { + get + { + return current_process; + } + } + + protected string strPerpetratorDN; + public string PerpetratorDN + { + get + { + return strPerpetratorDN; + } + } + + protected int[] integer_values; + public int[] IntegerValues + { + get + { + return integer_values; + } + } + + protected string[] string_values; + public string[] StringValues + { + get + { + return string_values; + } + } + + public GeneralDSEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + ds_time = getTaggedIntValue( + (Asn1Tagged) decoder.decode(decodedData, length), + GeneralEventField.EVT_TAG_GEN_DSTIME); + milli_seconds = getTaggedIntValue( + (Asn1Tagged) decoder.decode(decodedData, length), + GeneralEventField.EVT_TAG_GEN_MILLISEC); + + nVerb = getTaggedIntValue( + (Asn1Tagged) decoder.decode(decodedData, length), + GeneralEventField.EVT_TAG_GEN_VERB); + current_process = getTaggedIntValue( + (Asn1Tagged) decoder.decode(decodedData, length), + GeneralEventField.EVT_TAG_GEN_CURRPROC); + + strPerpetratorDN = getTaggedStringValue( + (Asn1Tagged) decoder.decode(decodedData, length), + GeneralEventField.EVT_TAG_GEN_PERP); + + Asn1Tagged temptaggedvalue = + ((Asn1Tagged) decoder.decode(decodedData, length)); + + if (temptaggedvalue.getIdentifier().Tag + == (int) GeneralEventField.EVT_TAG_GEN_INTEGERS) + { + //Integer List. + Asn1Sequence inteseq = getTaggedSequence(temptaggedvalue, GeneralEventField.EVT_TAG_GEN_INTEGERS); + Asn1Object[] intobject = inteseq.toArray(); + integer_values = new int[intobject.Length]; + + for (int i = 0; i < intobject.Length; i++) + { + integer_values[i] = ((Asn1Integer) intobject[i]).intValue(); + } + + //second decoding for Strings. + temptaggedvalue = ((Asn1Tagged) decoder.decode(decodedData, length)); + } + else + { + integer_values = null; + } + + if ((temptaggedvalue.getIdentifier().Tag + == (int) GeneralEventField.EVT_TAG_GEN_STRINGS) + && (temptaggedvalue.getIdentifier().Constructed)) + { + //String values. + Asn1Sequence inteseq = + getTaggedSequence(temptaggedvalue, GeneralEventField.EVT_TAG_GEN_STRINGS); + Asn1Object[] stringobject = inteseq.toArray(); + string_values = new string[stringobject.Length]; + + for (int i = 0; i < stringobject.Length; i++) + { + string_values[i] = + ((Asn1OctetString) stringobject[i]).stringValue(); + } + } + else + { + string_values = null; + } + + DataInitDone(); + } + + protected int getTaggedIntValue(Asn1Tagged tagvalue, GeneralEventField tagid) + { + Asn1Object obj = tagvalue.taggedValue(); + + if ((int)tagid != tagvalue.getIdentifier().Tag) + { + throw new IOException("Unknown Tagged Data"); + } + + byte[] dbytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue()); + MemoryStream data = new MemoryStream(dbytes); + + LBERDecoder dec = new LBERDecoder(); + + int length = dbytes.Length; + + return (int)(dec.decodeNumeric(data, length)); + } + + protected string getTaggedStringValue(Asn1Tagged tagvalue, GeneralEventField tagid) + { + Asn1Object obj = tagvalue.taggedValue(); + + if ((int)tagid != tagvalue.getIdentifier().Tag) + { + throw new IOException("Unknown Tagged Data"); + } + + byte[] dbytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue()); + MemoryStream data = new MemoryStream(dbytes); + + LBERDecoder dec = new LBERDecoder(); + + int length = dbytes.Length; + + return (string) dec.decodeCharacterString(data, length); + } + + protected Asn1Sequence getTaggedSequence(Asn1Tagged tagvalue, GeneralEventField tagid) + { + Asn1Object obj = tagvalue.taggedValue(); + + if ((int)tagid != tagvalue.getIdentifier().Tag) + { + throw new IOException("Unknown Tagged Data"); + } + + byte[] dbytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue()); + MemoryStream data = new MemoryStream(dbytes); + + LBERDecoder dec = new LBERDecoder(); + int length = dbytes.Length; + + return new Asn1Sequence(dec, data, length); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + + buf.Append("[GeneralDSEventData"); + buf.AppendFormat("(DSTime={0})", ds_time); + buf.AppendFormat("(MilliSeconds={0})", milli_seconds); + buf.AppendFormat("(verb={0})",nVerb); + buf.AppendFormat("(currentProcess={0})", current_process); + buf.AppendFormat("(PerpetartorDN={0})", strPerpetratorDN); + buf.AppendFormat("(Integer Values={0})", integer_values); + buf.AppendFormat("(String Values={0})", string_values); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ModuleStateEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ModuleStateEventData.cs new file mode 100644 index 00000000000..d8b4ee841a2 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ModuleStateEventData.cs @@ -0,0 +1,119 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.ModuleStateEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Module State Events. + /// </summary> + public class ModuleStateEventData : BaseEdirEventData + { + protected string strConnectionDN; + public string ConnectionDN + { + get + { + return strConnectionDN; + } + } + + protected int nFlags; + public int Flags + { + get + { + return nFlags; + } + } + + protected string strName; + public string Name + { + get + { + return strName; + } + } + + protected string strDescription; + public string Description + { + get + { + return strDescription; + } + } + + protected string strSource; + public string Source + { + get + { + return strSource; + } + } + + public ModuleStateEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + strConnectionDN = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + nFlags = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strName = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strDescription = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strSource = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[ModuleStateEvent"); + buf.AppendFormat("(connectionDN={0})", strConnectionDN); + buf.AppendFormat("(flags={0})", nFlags); + buf.AppendFormat("(Name={0})", strName); + buf.AppendFormat("(Description={0})", strDescription); + buf.AppendFormat("(Source={0})", strSource); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/NetworkAddressEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/NetworkAddressEventData.cs new file mode 100644 index 00000000000..12edbc6f7d7 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/NetworkAddressEventData.cs @@ -0,0 +1,86 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.NetworkAddressEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Network Address Events. + /// </summary> + public class NetworkAddressEventData : BaseEdirEventData + { + protected int nType; + public int ValueType + { + get + { + return nType; + } + } + + protected string strData; + public string Data + { + get + { + return strData; + } + } + + public NetworkAddressEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + nType = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strData = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[NetworkAddress"); + buf.AppendFormat("(type={0})", nType); + buf.AppendFormat("(Data={0})", strData); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ReferralAddress.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ReferralAddress.cs new file mode 100644 index 00000000000..63ed8cf88b1 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ReferralAddress.cs @@ -0,0 +1,69 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.ReferralAddress.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Address(IP/IPX/IPV6 etc) datastructure for + /// Edir Events Notification. + /// </summary> + public class ReferralAddress + { + protected int address_type; + public int AddressType + { + get + { + return address_type; + } + } + + protected string strAddress; + public string Address + { + get + { + return strAddress; + } + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public ReferralAddress(Asn1Sequence dseObject) + { + address_type = ((Asn1Integer) dseObject.get_Renamed(0)).intValue(); + strAddress = ((Asn1OctetString) dseObject.get_Renamed(1)).stringValue(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/SecurityEquivalenceEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/SecurityEquivalenceEventData.cs new file mode 100644 index 00000000000..a970b78b61d --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/SecurityEquivalenceEventData.cs @@ -0,0 +1,133 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.SecurityEquivalenceEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Collections; +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Security Equivalence Events. + /// </summary> + public class SecurityEquivalenceEventData : BaseEdirEventData + { + protected string strEntryDN; + public string EntryDN + { + get + { + return strEntryDN; + } + } + + protected int retry_count; + public int RetryCount + { + get + { + return retry_count; + } + } + + protected string strValueDN; + public string ValueDN + { + get + { + return strValueDN; + } + } + + protected int referral_count; + public int ReferralCount + { + get + { + return referral_count; + } + } + + protected ArrayList referral_list; + public ArrayList ReferralList + { + get + { + return referral_list; + } + } + + public SecurityEquivalenceEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + strEntryDN = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + retry_count = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + strValueDN = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + Asn1Sequence referalseq = ((Asn1Sequence) decoder.decode(decodedData, length)); + + referral_count = ((Asn1Integer) referalseq.get_Renamed(0)).intValue(); + referral_list = new ArrayList(); + if (referral_count > 0) + { + Asn1Sequence referalseqof = ((Asn1Sequence) referalseq.get_Renamed(1)); + + for (int i = 0; i < referral_count; i++) + { + referral_list.Add( new ReferralAddress( (Asn1Sequence) referalseqof.get_Renamed(i) ) ); + } + } + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + buf.Append("[SecurityEquivalenceEventData"); + buf.AppendFormat("(EntryDN={0})", strEntryDN); + buf.AppendFormat("(RetryCount={0})", retry_count); + buf.AppendFormat("(valueDN={0})", strValueDN); + buf.AppendFormat("(referralCount={0})", referral_count); + buf.AppendFormat("(Referral Lists={0})", referral_list); + buf.Append("]"); + + return buf.ToString(); + } + + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ValueEventData.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ValueEventData.cs new file mode 100644 index 00000000000..23a7720d946 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ValueEventData.cs @@ -0,0 +1,165 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.Edir.EventData.ValueEventData.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.IO; +using System.Text; + +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Events.Edir.EventData +{ + /// <summary> + /// This class represents the data for Value Events. + /// </summary> + public class ValueEventData : BaseEdirEventData + { + protected string strAttribute; + public string Attribute + { + get + { + return strAttribute; + } + } + + protected string strClassId; + public string ClassId + { + get + { + return strClassId; + } + } + + protected string strData; + public string Data + { + get + { + return strData; + } + } + + protected string strEntry; + public string Entry + { + get + { + return strEntry; + } + } + + protected string strPerpetratorDN; + public string PerpetratorDN + { + get + { + return strPerpetratorDN; + } + } + + // syntax + protected string strSyntax; + public string Syntax + { + get + { + return strSyntax; + } + } + + protected DSETimeStamp timeStampObj; + public DSETimeStamp TimeStamp + { + get + { + return timeStampObj; + } + } + + protected int nVerb; + public int Verb + { + get + { + return nVerb; + } + } + + public ValueEventData(EdirEventDataType eventDataType, Asn1Object message) + : base(eventDataType, message) + { + int[] length = new int[1]; + + strPerpetratorDN = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strEntry = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strAttribute = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + strSyntax = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + strClassId = + ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + timeStampObj = + new DSETimeStamp((Asn1Sequence) decoder.decode(decodedData, length)); + + strData = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue(); + + nVerb = ((Asn1Integer) decoder.decode(decodedData, length)).intValue(); + + DataInitDone(); + } + + /// <summary> + /// Returns a string representation of the object. + /// </summary> + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + + buf.Append("[ValueEventData"); + buf.AppendFormat("(Attribute={0})", strAttribute); + buf.AppendFormat("(Classid={0})", strClassId); + buf.AppendFormat("(Data={0})", strData); + buf.AppendFormat("(Entry={0})", strEntry); + buf.AppendFormat("(Perpetrator={0})", strPerpetratorDN); + buf.AppendFormat("(Syntax={0})", strSyntax); + buf.AppendFormat("(TimeStamp={0})", timeStampObj); + buf.AppendFormat("(Verb={0})", nVerb); + buf.Append("]"); + + return buf.ToString(); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/PSearchEventSource.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/PSearchEventSource.cs new file mode 100644 index 00000000000..cc8dfa748a8 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/PSearchEventSource.cs @@ -0,0 +1,280 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.PSearchEventSource.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +using System; +using Novell.Directory.Ldap.Controls; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This is the source class for Ldap events. + /// </summary> + public class PSearchEventSource : LdapEventSource + { + protected SearchResultEventHandler search_result_event; + + /// <summary> + /// Caller has to register with this event in order to be notified of + /// corresponding Ldap search result event. + /// </summary> + public event SearchResultEventHandler SearchResultEvent + { + add + { + search_result_event += value; + ListenerAdded(); + } + remove + { + search_result_event -= value; + ListenerRemoved(); + } + } + + protected SearchReferralEventHandler search_referral_event; + + /// <summary> + /// Caller has to register with this event in order to be notified of + /// corresponding Ldap search reference event. + /// </summary> + public event SearchReferralEventHandler SearchReferralEvent + { + add + { + search_referral_event += value; + ListenerAdded(); + } + remove + { + search_referral_event -= value; + ListenerRemoved(); + } + } + + /// <summary> + /// SearchResultEventHandler is the delegate definition for SearchResultEvent. + /// The client (listener) has to register using this delegate in order to + /// get corresponding Ldap events. + /// </summary> + public delegate + void SearchResultEventHandler( + object source, + SearchResultEventArgs objArgs + ); + + /// <summary> + /// SearchReferralEventHandler is the delegate definition for SearchReferralEvent. + /// The client (listener) has to register using this delegate in order to + /// get corresponding Ldap events. + /// </summary> + public delegate + void SearchReferralEventHandler( + object source, + SearchReferralEventArgs objArgs + ); + + protected override int GetListeners() + { + int nListeners = 0; + if (null != search_result_event) + nListeners = search_result_event.GetInvocationList().Length; + + if (null != search_referral_event) + nListeners += search_referral_event.GetInvocationList().Length; + + return nListeners; + } + + protected LdapConnection mConnection; + protected string mSearchBase; + protected int mScope; + protected string[] mAttrs; + protected string mFilter; + protected bool mTypesOnly; + protected LdapSearchConstraints mSearchConstraints; + protected LdapEventType mEventChangeType; + + protected LdapSearchQueue mQueue; + + // Constructor + public PSearchEventSource( + LdapConnection conn, + string searchBase, + int scope, + string filter, + string[] attrs, + bool typesOnly, + LdapSearchConstraints constraints, + LdapEventType eventchangetype, + bool changeonly + ) + { + // validate the input arguments + if ((conn == null) + || (searchBase == null) + || (filter == null) + || (attrs == null)) + { + throw new ArgumentException("Null argument specified"); + } + + mConnection = conn; + mSearchBase = searchBase; + mScope = scope; + mFilter = filter; + mAttrs = attrs; + mTypesOnly = typesOnly; + mEventChangeType = eventchangetype; + + // make things ready for starting a search operation + if (constraints == null) + { + mSearchConstraints = new LdapSearchConstraints(); + } + else + { + mSearchConstraints = constraints; + } + + //Create the persistent search control + LdapPersistSearchControl psCtrl = + new LdapPersistSearchControl((int)eventchangetype,// any change + changeonly, //only get changes + true, //return entry change controls + true); //control is critcal + + // add the persistent search control to the search constraints + mSearchConstraints.setControls(psCtrl); + } // end of Constructor + + protected override void StartSearchAndPolling() + { + // perform the search with no attributes returned + mQueue = + mConnection.Search(mSearchBase, // container to search + mScope, // search container's subtree + mFilter, // search filter, all objects + mAttrs, // don't return attributes + mTypesOnly, // return attrs and values or attrs only. + null, // use default search queue + mSearchConstraints); // use default search constraints + + int[] ids = mQueue.MessageIDs; + + if (ids.Length != 1) + { + throw new LdapException( + null, + LdapException.LOCAL_ERROR, + "Unable to Obtain Message Id" + ); + } + + StartEventPolling(mQueue, mConnection, ids[0]); + } + + protected override void StopSearchAndPolling() + { + mConnection.Abandon(mQueue); + StopEventPolling(); + } + + protected override bool NotifyEventListeners(LdapMessage sourceMessage, + EventClassifiers aClassification, + int nType) + { + bool bListenersNotified = false; + if (null == sourceMessage) + { + return bListenersNotified; + } + + switch (sourceMessage.Type) + { + case LdapMessage.SEARCH_RESULT_REFERENCE : + if (null != search_referral_event) + { + search_referral_event(this, + new SearchReferralEventArgs( + sourceMessage, + aClassification, + (LdapEventType)nType) + ); + bListenersNotified = true; + } + break; + + case LdapMessage.SEARCH_RESPONSE: + if (null != search_result_event) + { + LdapEventType changeType = LdapEventType.TYPE_UNKNOWN; + LdapControl[] controls = sourceMessage.Controls; + foreach(LdapControl control in controls) + { + if (control is LdapEntryChangeControl) + { + changeType = (LdapEventType)(((LdapEntryChangeControl)control).ChangeType); + // TODO: Why is this continue here..? (from Java code..) + // TODO: Why are we interested only in the last changeType..? + continue; + } + } + // if no changeType then value is TYPE_UNKNOWN + search_result_event(this, + new SearchResultEventArgs( + sourceMessage, + aClassification, + changeType) + ); + bListenersNotified = true; + } + break; + + case LdapMessage.SEARCH_RESULT: + // This is a generic LDAP Event + // TODO: Why the type is ANY...? (java code) + NotifyDirectoryListeners(new LdapEventArgs(sourceMessage, + EventClassifiers.CLASSIFICATION_LDAP_PSEARCH, + LdapEventType.LDAP_PSEARCH_ANY)); + bListenersNotified = true; + break; + + default: + // This seems to be some unknown event. + // Let this be notified to generic DirectoryListeners in the base class... + break; + } + + return bListenersNotified; + } + } // end of class PSearchEventSource +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchReferralEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchReferralEventArgs.cs new file mode 100644 index 00000000000..3b984e7971e --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchReferralEventArgs.cs @@ -0,0 +1,54 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.SearchReferralEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This class represents the EventArgs corresponding to + /// LdapSearchResultReference notification sent by Ldap Server. + /// </summary> + public class SearchReferralEventArgs : LdapEventArgs + { + public SearchReferralEventArgs(LdapMessage sourceMessage, + EventClassifiers aClassification, + LdapEventType aType) + : base(sourceMessage, EventClassifiers.CLASSIFICATION_LDAP_PSEARCH, + LdapEventType.LDAP_PSEARCH_ANY) // TODO: why type is ANY..? + { + } + + public string[] getUrls() { + return ((LdapSearchResultReference) ldap_message).Referrals; + } + + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchResultEventArgs.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchResultEventArgs.cs new file mode 100644 index 00000000000..0d91a769e03 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Events/SearchResultEventArgs.cs @@ -0,0 +1,114 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Events.SearchResultEventArgs.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System.Text; + +namespace Novell.Directory.Ldap.Events +{ + /// <summary> + /// This class represents the EventArgs corresponding to + /// LdapSearchResult notification sent by Ldap Server. + /// </summary> + public class SearchResultEventArgs : LdapEventArgs + { + public SearchResultEventArgs(LdapMessage sourceMessage, + EventClassifiers aClassification, + LdapEventType aType) + : base(sourceMessage, EventClassifiers.CLASSIFICATION_LDAP_PSEARCH, aType) + { + } + + public LdapEntry Entry + { + get + { + return ((LdapSearchResult) ldap_message).Entry; + } + } + + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + + buf.AppendFormat("[{0}:", GetType()); + buf.Append("(Classification=LDAP Persistence Search Event)"); + buf.AppendFormat("(Type={0})", getChangeTypeString()); + buf.AppendFormat("(EventInformation:{0})", getStringRepresentaionOfEventInformation()); + buf.Append("]"); + + return buf.ToString(); + } + + private string getStringRepresentaionOfEventInformation() + { + StringBuilder buf = new StringBuilder(); + LdapSearchResult result = (LdapSearchResult)ldap_message; + + buf.AppendFormat("(Entry={0})", result.Entry); + LdapControl[] controls = result.Controls; + + if (null != controls) + { + buf.Append("(Controls="); + int i = 0; + foreach(LdapControl control in controls) + { + buf.AppendFormat("(Control{0}={1})", ++i, control.ToString()); + } + buf.Append(")"); + } + + return buf.ToString(); + } + + private string getChangeTypeString() + { + switch (eType) + { + case LdapEventType.LDAP_PSEARCH_ADD: + return "ADD"; + + case LdapEventType.LDAP_PSEARCH_DELETE: + return "DELETE"; + + case LdapEventType.LDAP_PSEARCH_MODIFY: + return "MODIFY"; + + case LdapEventType.LDAP_PSEARCH_MODDN: + return "MODDN"; + + default: + return ("No change type: " + eType); + } + } + + } // end of class SearchResultEventArgs +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcIntermediateResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcIntermediateResponse.cs new file mode 100644 index 00000000000..f5a705833b3 --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcIntermediateResponse.cs @@ -0,0 +1,190 @@ +/****************************************************************************** + * The MIT License + * Copyright (c) 2003 Novell Inc. www.novell.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + *******************************************************************************/ +// +// Novell.Directory.Ldap.Rfc2251.RfcIntermediateResponse.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; +using LdapException = Novell.Directory.Ldap.LdapException; +using LdapMessage = Novell.Directory.Ldap.LdapMessage; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Rfc2251 +{ + /// <summary> + /// Represents an LDAP Intermediate Response. + /// + /// + /// IntermediateResponse ::= [APPLICATION 25] SEQUENCE { + /// COMPONENTS OF LDAPResult, note: only present on incorrectly + /// encoded response from + /// pre Falcon-sp1 server + /// responseName [10] LDAPOID OPTIONAL, + /// responseValue [11] OCTET STRING OPTIONAL } + /// </summary> + /// + public class RfcIntermediateResponse : Asn1Sequence, RfcResponse + { + /** + * Context-specific TAG for optional responseName. + */ + public const int TAG_RESPONSE_NAME = 0; + /** + * Context-specific TAG for optional response. + */ + public const int TAG_RESPONSE = 1; + + private int m_referralIndex; + private int m_responseNameIndex; + private int m_responseValueIndex; + + + //************************************************************************* + // Constructors for ExtendedResponse + //************************************************************************* + + /** + * The only time a client will create a IntermediateResponse is when it is + * decoding it from an InputStream. The stream contains the intermediate + * response sequence that follows the msgID in the PDU. The intermediate + * response draft defines this as: + * IntermediateResponse ::= [APPLICATION 25] SEQUENCE { + * responseName [0] LDAPOID OPTIONAL, + * responseValue [1] OCTET STRING OPTIONAL } + * + * Until post Falcon sp1, the LDAP server was incorrectly encoding + * intermediate response as: + * IntermediateResponse ::= [APPLICATION 25] SEQUENCE { + * Components of LDAPResult, + * responseName [0] LDAPOID OPTIONAL, + * responseValue [1] OCTET STRING OPTIONAL } + * + * where the Components of LDAPResult are + * resultCode ENUMERATED {...} + * matchedDN LDAPDN, + * errorMessage LDAPString, + * referral [3] Referral OPTIONAL } + * + * + * (The components of LDAPResult never have the optional referral.) + * This constructor is written to handle both cases. + * + * The sequence of this intermediate response will have the element + * at index m_responseNameIndex set to an RfcLDAPOID containing the + * oid of the response. The element at m_responseValueIndex will be set + * to an ASN1OctetString containing the value bytes. + */ + [CLSCompliantAttribute(false)] + public RfcIntermediateResponse(Asn1Decoder dec, System.IO.Stream in_Renamed, int len) : base(dec, in_Renamed, len) + // throws IOException + { + // super(dec, in, len); + + int i=0; + m_responseNameIndex = m_responseValueIndex = 0; + + // decode optional tagged elements. The parent class constructor will + // have decoded these elements as ASN1Tagged objects with the value + // stored as an ASN1OctectString object. + + if(size() >= 3) //the incorrectly encoded case, LDAPResult contains + i = 3; //at least 3 components + else + i = 0; //correctly encoded case, can have zero components + + for(; i<size(); i++) + { + Asn1Tagged obj = (Asn1Tagged)get_Renamed(i); + Asn1Identifier id = obj.getIdentifier(); + switch(id.Tag) + { + case TAG_RESPONSE_NAME: + set_Renamed(i, new RfcLdapOID( + ((Asn1OctetString)obj.taggedValue()).byteValue())); + m_responseNameIndex = i; + break; + + case TAG_RESPONSE: + set_Renamed(i, obj.taggedValue()); + m_responseValueIndex = i; + break; + } + } + } + + public Asn1Enumerated getResultCode() + { + if ( size() > 3) + return (Asn1Enumerated)get_Renamed(0); + else + return null; + } + + public RfcLdapDN getMatchedDN() + { + if ( size() > 3) + return new RfcLdapDN(((Asn1OctetString)get_Renamed(1)).byteValue()); + else + return null; + } + + public RfcLdapString getErrorMessage() + { + if ( size() > 3) + return new RfcLdapString(((Asn1OctetString)get_Renamed(2)).byteValue()); + else + return null; + } + + public RfcReferral getReferral() + { + return (size() > 3) ? (RfcReferral)get_Renamed(3) : null; + } + + public RfcLdapOID getResponseName() + { + return (m_responseNameIndex != 0) ? (RfcLdapOID)get_Renamed(m_responseNameIndex) + : null; + } + + public Asn1OctetString getResponse() + { + return (m_responseValueIndex != 0) ? (Asn1OctetString)get_Renamed(m_responseValueIndex) + : null; + } + + /** + * Override getIdentifier to return an application-wide id. + */ + public override Asn1Identifier getIdentifier() + { + return new Asn1Identifier(Asn1Identifier.APPLICATION, true, + LdapMessage.INTERMEDIATE_RESPONSE); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs index d1cc85f558b..9fa939f529d 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs @@ -269,6 +269,10 @@ namespace Novell.Directory.Ldap.Rfc2251 set_Renamed(1, new RfcExtendedResponse(dec, bais, content.Length)); break; + case LdapMessage.INTERMEDIATE_RESPONSE: + set_Renamed(1, new RfcIntermediateResponse(dec, bais, content.Length)); + break; + case LdapMessage.MODIFY_RESPONSE: set_Renamed(1, new RfcModifyResponse(dec, bais, content.Length)); break; diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/IntermediateResponseFactory.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/IntermediateResponseFactory.cs new file mode 100644 index 00000000000..ed504048b7f --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/IntermediateResponseFactory.cs @@ -0,0 +1,119 @@ +/****************************************************************************** +* The MIT License +* Copyright (c) 2003 Novell Inc. www.novell.com +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the Software), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*******************************************************************************/ +// +// Novell.Directory.Ldap.Utilclass.IntermediateResponseFactory.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; +using System.Reflection; + +using Novell.Directory.Ldap; +using Novell.Directory.Ldap.Rfc2251; + +namespace Novell.Directory.Ldap.Utilclass +{ + /// <summary> + /// + /// Takes an LDAPIntermediateResponse and returns an object + /// (that implements the base class LDAPIntermediateResponse) + /// based on the OID. + /// + /// You can then call methods defined in the child + /// class to parse the contents of the response. The methods available + /// depend on the child class. All child classes inherit from the + /// LdapIntermediateResponse. + /// + /// </summary> +public class IntermediateResponseFactory +{ + + /** + * Used to Convert an RfcLDAPMessage object to the appropriate + * LDAPIntermediateResponse object depending on the operation being performed. + * + * @param inResponse The LDAPIntermediateResponse object as returned by the + * extendedOperation method in the LDAPConnection object. + * <br><br> + * @return An object of base class LDAPIntermediateResponse. The actual child + * class of this returned object depends on the operation being + * performed. + * + * @exception LDAPException A general exception which includes an error message + * and an LDAP error code. + */ + + static public LdapIntermediateResponse convertToIntermediateResponse(RfcLdapMessage inResponse) + // throws LDAPException + { + + LdapIntermediateResponse tempResponse = new LdapIntermediateResponse(inResponse); + // Get the oid stored in the Extended response + String inOID = tempResponse.getID(); + + RespExtensionSet regExtResponses = + LdapIntermediateResponse.getRegisteredResponses(); + try{ + Type extRespClass = regExtResponses.findResponseExtension(inOID); + if ( extRespClass == null ){ + return tempResponse; + } + + Type[] argsClass = new Type[]{typeof(RfcLdapMessage)}; + Object[] args = { inResponse }; + Exception ex; + try{ + ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass); + + try{ + Object resp = null; + resp = extConstructor.Invoke(args); + return (LdapIntermediateResponse) resp; + } catch (UnauthorizedAccessException e) { + ex = e; + } catch (TargetInvocationException e) { + ex = e; + } + } catch (MissingMethodException e) { + // bad class was specified, fall through and return a + // default LDAPIntermediateResponse object + ex = e; + } + } catch (MissingFieldException e) { + // No match with the OID + // Do nothing. Fall through and construct a default LDAPControl object. + + } + // If we get here we did not have a registered extendedresponse + // for this oid. Return a default LDAPIntermediateResponse object. + return tempResponse; + } + +} + +} + diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources index c0d02f05bdf..526f1908eaa 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources @@ -18,6 +18,7 @@ Novell.Directory.Ldap.Utilclass/TokenTypes.cs Novell.Directory.Ldap.Utilclass/CharacterTypes.cs Novell.Directory.Ldap.Utilclass/SchemaTokenCreator.cs Novell.Directory.Ldap.Utilclass/SchemaParser.cs +Novell.Directory.Ldap.Utilclass/IntermediateResponseFactory.cs Novell.Directory.Ldap.Asn1/Asn1Boolean.cs Novell.Directory.Ldap.Asn1/Asn1Choice.cs Novell.Directory.Ldap.Asn1/Asn1Encoder.cs @@ -83,6 +84,7 @@ Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs +Novell.Directory.Ldap.Rfc2251/RfcIntermediateResponse.cs Novell.Directory.Ldap/LdapConnection.cs Novell.Directory.Ldap/LdapAuthHandler.cs Novell.Directory.Ldap/LdapBindHandler.cs @@ -138,6 +140,7 @@ Novell.Directory.Ldap/LdapNameFormSchema.cs Novell.Directory.Ldap/LdapControl.cs Novell.Directory.Ldap/LdapException.cs Novell.Directory.Ldap/LdapMessage.cs +Novell.Directory.Ldap/LdapIntermediateResponse.cs Novell.Directory.Ldap.Extensions/AbortPartitionOperationRequest.cs Novell.Directory.Ldap.Extensions/AddReplicaRequest.cs Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs @@ -174,3 +177,33 @@ Novell.Directory.Ldap.Controls/LdapSortKey.cs Novell.Directory.Ldap.Controls/LdapSortResponse.cs Novell.Directory.Ldap.Controls/LdapVirtualListControl.cs Novell.Directory.Ldap.Controls/LdapVirtualListResponse.cs +Novell.Directory.Ldap.Events/LdapEventConstants.cs +Novell.Directory.Ldap.Events/BaseEventArgs.cs +Novell.Directory.Ldap.Events/DirectoryExceptionEventArgs.cs +Novell.Directory.Ldap.Events/DirectoryEventArgs.cs +Novell.Directory.Ldap.Events/LdapEventArgs.cs +Novell.Directory.Ldap.Events/LdapEventSource.cs +Novell.Directory.Ldap.Events/SearchResultEventArgs.cs +Novell.Directory.Ldap.Events/SearchReferralEventArgs.cs +Novell.Directory.Ldap.Events/PSearchEventSource.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventConstants.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventArgs.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSpecifier.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BaseEdirEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DSETimeStamp.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/EntryEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ValueEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ReferralAddress.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugParameter.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/DebugEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/GeneralDSEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/BinderyObjectEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/SecurityEquivalenceEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ModuleStateEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/NetworkAddressEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ConnectionStateEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/Novell.Directory.Ldap.Events.Edir.EventData/ChangeAddressEventData.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventIntermediateResponse.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventResponse.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/MonitorEventRequest.cs +Novell.Directory.Ldap.Events/Novell.Directory.Ldap.Events.Edir/EdirEventSource.cs diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs index e163ce006fc..98d3816cd9a 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Connection.cs @@ -34,6 +34,18 @@ using System.Threading; using Novell.Directory.Ldap.Asn1; using Novell.Directory.Ldap.Rfc2251; using Novell.Directory.Ldap.Utilclass; +using Mono.Security.Protocol.Tls; +using Mono.Security.X509.Extensions; +using Syscert = System.Security.Cryptography.X509Certificates; +using System.Security.Cryptography; +using System.Net; +using System.Net.Sockets; +using System.Collections; +using System.IO; +using System.Text; +using Mono.Security.X509; +using System.Text.RegularExpressions; +using System.Globalization; namespace Novell.Directory.Ldap { @@ -86,6 +98,20 @@ namespace Novell.Directory.Ldap } } + + + + internal bool Ssl + { + get + { + return ssl; + } + set + { + ssl=value; + } + } /// <summary> gets the host used for this connection</summary> internal System.String Host { @@ -275,6 +301,7 @@ namespace Novell.Directory.Ldap * if nonTLSBackup is null then startTLS has not been called, * or stopTLS has been called to end TLS protection */ + private System.Net.Sockets.Socket sock = null; private System.Net.Sockets.TcpClient socket = null; private System.Net.Sockets.TcpClient nonTLSBackup = null; @@ -283,6 +310,8 @@ namespace Novell.Directory.Ldap // When set to true the client connection is up and running private bool clientActive = true; + private bool ssl = false; + // Indicates we have received a server shutdown unsolicited notification private bool unsolSvrShutDnNotification = false; @@ -575,7 +604,46 @@ namespace Novell.Directory.Ldap connect(host, port, 0); return ; } - + + +/****************************************************************************/ + public bool ServerCertificateValidation( + Syscert.X509Certificate certificate, + int[] certificateErrors) + { + + bool retFlag=false; + + if (certificateErrors != null && + certificateErrors.Length > 0) + { + if( certificateErrors.Length==1 && certificateErrors[0] == -2146762481) + { + retFlag = true; + } + else + { + Console.WriteLine("Detected errors in the Server Certificate:"); + + for (int i = 0; i < certificateErrors.Length; i++) + { + Console.WriteLine(certificateErrors[i]); + } + retFlag = false; + } + } + else + { + retFlag = true; + } + + + // Skip the server cert errors. + return retFlag; + } + + +/***********************************************************************/ /// <summary> Constructs a TCP/IP connection to a server specified in host and port. /// Starts the reader thread. /// @@ -614,10 +682,32 @@ namespace Novell.Directory.Ldap { if ((in_Renamed == null) || (out_Renamed == null)) { - socket = new System.Net.Sockets.TcpClient(host, port); - - in_Renamed = (System.IO.Stream) socket.GetStream(); - out_Renamed = (System.IO.Stream) socket.GetStream(); + if(Ssl) + { + this.host = host; + this.port = port; + this.sock = new Socket ( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); + IPAddress hostadd = Dns.Resolve(host).AddressList[0]; + IPEndPoint ephost = new IPEndPoint(hostadd,port); + sock.Connect(ephost); + NetworkStream nstream = new NetworkStream(sock,true); + SslClientStream sslstream = new SslClientStream( + nstream, + host, + false, + Mono.Security.Protocol.Tls.SecurityProtocolType.Ssl3|Mono.Security.Protocol.Tls.SecurityProtocolType.Tls); + sslstream.ServerCertValidationDelegate += new CertificateValidationCallback(ServerCertificateValidation); +// byte[] buffer = new byte[0]; +// sslstream.Read(buffer, 0, buffer.Length); +// sslstream.doHandshake(); + in_Renamed = (System.IO.Stream) sslstream; + out_Renamed = (System.IO.Stream) sslstream; + } + else{ + socket = new System.Net.Sockets.TcpClient(host, port); + in_Renamed = (System.IO.Stream) socket.GetStream(); + out_Renamed = (System.IO.Stream) socket.GetStream(); + } } else { @@ -688,7 +778,7 @@ namespace Novell.Directory.Ldap lock (this) { Connection conn = this; - + if (cloneCount > 0) { cloneCount--; @@ -898,6 +988,7 @@ namespace Novell.Directory.Ldap sbyte[] ber = msg.Asn1Object.getEncoding(encoder); out_Renamed.Write(SupportClass.ToByteArray(ber), 0, ber.Length); out_Renamed.Flush(); + } catch (System.Exception ex) { @@ -913,13 +1004,20 @@ namespace Novell.Directory.Ldap // Close the socket try { - socket.Close(); + if(Ssl) + { + sock.Shutdown(SocketShutdown.Both); + sock.Close(); + } + else + socket.Close(); } catch (System.IO.IOException ie) { // ignore problem closing socket } socket = null; + sock = null; } freeWriteSemaphore(semId); return ; @@ -988,6 +1086,18 @@ namespace Novell.Directory.Ldap return ; } + /// <summary> Indicates if the conenction is using TLS protection + /// + /// Return true if using TLS protection + /// </summary> + internal bool TLS + { + get + { + return (this.nonTLSBackup != null); + } + } + /// <summary> StartsTLS, in this package, assumes the caller has: /// 1) Acquired the writeSemaphore /// 2) Stopped the reader thread @@ -1001,43 +1111,42 @@ namespace Novell.Directory.Ldap /// and start the reader thread. /// </summary> /* package */ -/* internal void startTLS() + internal void startTLS() { - if (this.mySocketFactory == null) - { - throw new LdapException(ExceptionMessages.NO_TLS_FACTORY, LdapException.TLS_NOT_SUPPORTED, null); - } - else if (!(this.mySocketFactory is LdapTLSSocketFactory)) - { - throw new LdapException(ExceptionMessages.WRONG_FACTORY, LdapException.TLS_NOT_SUPPORTED, null); - } try { waitForReader(null); this.nonTLSBackup = this.socket; - this.socket = ((LdapTLSSocketFactory) this.mySocketFactory).createSocket(this.socket); - this.in_Renamed = (System.IO.Stream) socket.GetStream(); - this.out_Renamed = (System.IO.Stream) socket.GetStream(); - - if (Debug.Ldap_DEBUG) - { - Debug.trace(Debug.TLS, "connection.startTLS, nonTLSBackup:" + nonTLSBackup + ", TLSSocket:" + socket + ", input:" + in_Renamed + "," + "output:" + out_Renamed); - } +/* this.sock = new Socket ( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); + IPAddress hostadd = Dns.Resolve(host).AddressList[0]; + IPEndPoint ephost = new IPEndPoint(hostadd,port); + sock.Connect(ephost); +*/ +// NetworkStream nstream = new NetworkStream(this.socket,true); + SslClientStream sslstream = new SslClientStream( + socket.GetStream(), +// nstream, + host, + false, + Mono.Security.Protocol.Tls.SecurityProtocolType.Ssl3| Mono.Security.Protocol.Tls.SecurityProtocolType.Tls); + sslstream.ServerCertValidationDelegate = new CertificateValidationCallback(ServerCertificateValidation); + this.in_Renamed = (System.IO.Stream) sslstream; + this.out_Renamed = (System.IO.Stream) sslstream; } - catch (System.Exception uhe) + catch (System.IO.IOException ioe) { this.nonTLSBackup = null; - throw new LdapException("The host is unknown", LdapException.CONNECT_ERROR, null, uhe); + throw new LdapException("Could not negotiate a secure connection", LdapException.CONNECT_ERROR, null, ioe); } - catch (System.IO.IOException ioe) + catch (System.Exception uhe) { this.nonTLSBackup = null; - throw new LdapException("Could not negotiate a secure connection", LdapException.CONNECT_ERROR, null, ioe); + throw new LdapException("The host is unknown", LdapException.CONNECT_ERROR, null, uhe); } return ; } -*/ + /* * Stops TLS. * @@ -1060,20 +1169,19 @@ namespace Novell.Directory.Ldap * IBM's JSSE hangs when you close the JSSE socket. */ /* package */ -/* internal void stopTLS() + internal void stopTLS() { try { this.stopReaderMessageID = Connection.STOP_READING; - this.socket.Close(); + this.out_Renamed.Close(); + this.in_Renamed.Close(); +// this.sock.Shutdown(SocketShutdown.Both); +// this.sock.Close(); waitForReader(null); this.socket = this.nonTLSBackup; this.in_Renamed = (System.IO.Stream) this.socket.GetStream(); this.out_Renamed = (System.IO.Stream) this.socket.GetStream(); - if (Debug.Ldap_DEBUG) - { - Debug.trace(Debug.TLS, "connection.stopTLS, nonTLSBackup:" + nonTLSBackup + ", TLSSocket:" + socket + ", input:" + in_Renamed + "," + "output:" + out_Renamed); - } // Allow the new reader to start this.stopReaderMessageID = Connection.CONTINUE_READING; } @@ -1088,7 +1196,7 @@ namespace Novell.Directory.Ldap } return ; } -*///TLS not supported in first release +///TLS not supported in first release public class ReaderThread { @@ -1380,7 +1488,7 @@ namespace Novell.Directory.Ldap static Connection() { nameLock = new System.Object(); - sdk = new System.Text.StringBuilder("3.0").ToString(); + sdk = new System.Text.StringBuilder("2.1.1").ToString(); protocol = 3; } } diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs index a217f3b7faa..973516b0d45 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapConnection.cs @@ -34,6 +34,8 @@ using Novell.Directory.Ldap; using Novell.Directory.Ldap.Asn1; using Novell.Directory.Ldap.Rfc2251; using Novell.Directory.Ldap.Utilclass; +using Mono.Security.Protocol.Tls; +using System.Security.Cryptography.X509Certificates; namespace Novell.Directory.Ldap { @@ -304,6 +306,30 @@ namespace Novell.Directory.Ldap } } + + + ///<summary> Indicates whther the perform Secure Operation or not + ///</summary> + /// + ///<returns> + /// True if SSL is on + /// False if its not on + ///</returns> + public bool SecureSocketLayer + { + get + { + return conn.Ssl; + } + set + { + conn.Ssl=value; + } + } + + + + /// <summary> Indicates whether the object has authenticated to the connected Ldap /// server. /// @@ -334,6 +360,26 @@ namespace Novell.Directory.Ldap } } + + /// <summary> Indicatates if the connection is protected by TLS. + /// + /// </summary> + /// <returns> If startTLS has completed this method returns true. + /// If stopTLS has completed or start tls failed, this method returns false. + /// </returns> + /// <returns> True if the connection is protected by TLS. + /// + /// </returns> + virtual public bool TLS + { + get + { + return conn.TLS; + } + + } + + /// <summary> Returns the Server Controls associated with the most recent response /// to a synchronous request on this connection object, or null /// if the latest response contained no Server Controls. The method @@ -550,6 +596,16 @@ namespace Novell.Directory.Ldap conn = new Connection(); return ; } + +/* public LdapConnection(X509Certificate cert) + { + InitBlock(); + // Get a unique connection name for debug + conn = new Connection(); + conn.Cert = cert; + return ; + } +*/ /* * The following are methods that affect the operation of * LdapConnection, but are not Ldap requests. @@ -728,6 +784,87 @@ namespace Novell.Directory.Ldap /// LdapTLSSocketFactory an LdapException is thrown. /// /// </exception> + + public virtual void startTLS() + { + + LdapMessage startTLS = MakeExtendedOperation(new LdapExtendedOperation(LdapConnection.START_TLS_OID, null), null); + + int tlsID = startTLS.MessageID; + + conn.acquireWriteSemaphore(tlsID); + try + { + if (!conn.areMessagesComplete()) + { + throw new LdapLocalException(ExceptionMessages.OUTSTANDING_OPERATIONS, LdapException.OPERATIONS_ERROR); + } + // Stop reader when response to startTLS request received + conn.stopReaderOnReply(tlsID); + + // send tls message + LdapResponseQueue queue = SendRequestToServer(startTLS, defSearchCons.TimeLimit, null, null); + + LdapExtendedResponse response = (LdapExtendedResponse) queue.getResponse(); + response.chkResultCode(); + + conn.startTLS(); + } + finally + { + //Free this semaphore no matter what exceptions get thrown + conn.startReader(); + conn.freeWriteSemaphore(tlsID); + } + return ; + } + + /// <summary> Stops Transport Layer Security(TLS) on the LDAPConnection and reverts + /// back to an anonymous state. + /// + /// @throws LDAPException This can occur for the following reasons: + /// <UL> + /// <LI>StartTLS has not been called before stopTLS</LI> + /// <LI>There exists outstanding messages that have not received all + /// responses</LI> + /// <LI>The sever was not able to support the operation</LI></UL> + /// + /// <p>Note: The Sun and IBM implementions of JSSE do not currently allow + /// stopping TLS on an open Socket. In order to produce the same results + /// this method currently disconnects the socket and reconnects, giving + /// the application an anonymous connection to the server, as required + /// by StopTLS</p> + /// </summary> + public virtual void stopTLS() + { + + if (!TLS) + { + throw new LdapLocalException(ExceptionMessages.NO_STARTTLS, LdapException.OPERATIONS_ERROR); + } + + int semaphoreID = conn.acquireWriteSemaphore(); + try + { + if (!conn.areMessagesComplete()) + { + throw new LdapLocalException(ExceptionMessages.OUTSTANDING_OPERATIONS, LdapException.OPERATIONS_ERROR); + } + //stopTLS stops and starts the reader thread for us. + conn.stopTLS(); + } + finally + { + conn.freeWriteSemaphore(semaphoreID); + + /* Now that the TLS socket is closed, reset everything. This next + line is temporary until JSSE is fixed to properly handle TLS stop */ + this.Connect(this.Host, this.Port); + } + return ; + } + + //************************************************************************* // Below are all of the Ldap protocol operation methods //************************************************************************* diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDSConstants.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDSConstants.cs index afce618b879..3a0821d6b2d 100644 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDSConstants.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapDSConstants.cs @@ -1,24 +1,3 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// /****************************************************************************** * The MIT License * Copyright (c) 2003 Novell Inc. www.novell.com diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapIntermediateResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapIntermediateResponse.cs new file mode 100644 index 00000000000..c759383432f --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapIntermediateResponse.cs @@ -0,0 +1,118 @@ +/****************************************************************************** + * The MIT License + * Copyright (c) 2003 Novell Inc. www.novell.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + *******************************************************************************/ +// +// Novell.Directory.Ldap.LdapIntermediateResponse.cs +// +// Author: +// Anil Bhatia (banil@novell.com) +// +// (C) 2003 Novell, Inc (http://www.novell.com) +// + +using System; +using Novell.Directory.Ldap.Asn1; +using Novell.Directory.Ldap.Rfc2251; +using Novell.Directory.Ldap.Utilclass; + +namespace Novell.Directory.Ldap +{ + /** + * + * Encapsulates the response returned by an LDAP server on an + * asynchronous extended operation request. It extends LdapResponse. + * + * The response can contain the OID of the extension, an octet string + * with the operation's data, both, or neither. + */ + public class LdapIntermediateResponse : LdapResponse + { + private static RespExtensionSet registeredResponses = new RespExtensionSet(); + + /** + * Registers a class to be instantiated on receipt of a extendedresponse + * with the given OID. + * + * <p>Any previous registration for the OID is overridden. The + * extendedResponseClass object MUST be an extension of + * LdapIntermediateResponse. </p> + * + * @param oid The object identifier of the control. + * <br><br> + * @param extendedResponseClass A class which can instantiate an + * LdapIntermediateResponse. + */ + public static void register(String oid, Type extendedResponseClass) + { + registeredResponses.registerResponseExtension(oid, extendedResponseClass); + return; + } + + /* package */ + public static RespExtensionSet getRegisteredResponses() + { + return registeredResponses; + } + + + /** + * Creates an LdapIntermediateResponse object which encapsulates + * a server response to an asynchronous extended operation request. + * + * @param message The RfcLdapMessage to convert to an + * LdapIntermediateResponse object. + */ + public LdapIntermediateResponse(RfcLdapMessage message) : base(message) + { + } + + /** + * Returns the message identifier of the response. + * + * @return OID of the response. + */ + public String getID() + { + RfcLdapOID respOID = + ((RfcIntermediateResponse)message.Response).getResponseName(); + if (respOID == null) + return null; + return respOID.stringValue(); + } + + /** + * Returns the value part of the response in raw bytes. + * + * @return The value of the response. + */ + [CLSCompliantAttribute(false)] + public sbyte[] getValue() + { + Asn1OctetString tempString = + ((RfcIntermediateResponse)message.Response).getResponse(); + if (tempString == null) + return null; + else + return(tempString.byteValue()); + } + } +} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs index e480ca8d922..d5adc5df235 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessage.cs @@ -161,6 +161,7 @@ namespace Novell.Directory.Ldap /// <li>SEARCH_RESULT_REFERENCE = 19;</li> /// <li>EXTENDED_REQUEST = 23;</li> /// <li>EXTENDED_RESPONSE = 24;</li> + /// <li>INTERMEDIATE_RESPONSE = 25;</li> /// </ul> /// /// </summary> @@ -290,6 +291,10 @@ namespace Novell.Directory.Ldap case EXTENDED_RESPONSE: name = "LdapExtendedResponse"; break; + + case INTERMEDIATE_RESPONSE: + name = "LdapIntermediateResponse"; + break; default: throw new System.SystemException("LdapMessage: Unknown Type " + Type); @@ -484,7 +489,13 @@ namespace Novell.Directory.Ldap /// EXTENDED_RESONSE = 24 /// </summary> public const int EXTENDED_RESPONSE = 24; - + + /// <summary> An intermediate response operation. + /// + /// INTERMEDIATE_RESONSE = 25 + /// </summary> + public const int INTERMEDIATE_RESPONSE = 25; + /// <summary> A request or response message for an asynchronous Ldap operation.</summary> protected internal RfcLdapMessage message; diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs index 9a71a2e0903..3ca8737f343 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapMessageQueue.cs @@ -32,6 +32,7 @@ using System; using RfcLdapMessage = Novell.Directory.Ldap.Rfc2251.RfcLdapMessage; using ExtResponseFactory = Novell.Directory.Ldap.Utilclass.ExtResponseFactory; +using IntermediateResponseFactory = Novell.Directory.Ldap.Utilclass.IntermediateResponseFactory; namespace Novell.Directory.Ldap { @@ -218,7 +219,11 @@ namespace Novell.Directory.Ldap ExtResponseFactory fac = new ExtResponseFactory(); response = ExtResponseFactory.convertToExtendedResponse(message); break; - + + case LdapMessage.INTERMEDIATE_RESPONSE : + response = IntermediateResponseFactory.convertToIntermediateResponse(message); + break; + default: response = new LdapResponse(message); break; diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs index 2ea9955d58a..9e01520c0a0 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralHandler.cs @@ -1,24 +1,3 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// /****************************************************************************** * The MIT License * Copyright (c) 2003 Novell Inc. www.novell.com diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSchema.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSchema.cs index 667ed188b50..90c03098dc5 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSchema.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSchema.cs @@ -445,7 +445,6 @@ namespace Novell.Directory.Ldap //All non schema attributes are ignored. continue; } - return ; } /// <summary> Adds the schema definition to the idList and nameList HashMaps. diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs index d63a6f03f9d..75112875c78 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapSearchResultReference.cs @@ -1,24 +1,3 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// /****************************************************************************** * The MIT License * Copyright (c) 2003 Novell Inc. www.novell.com diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs index b36d6180344..8f70e3f066f 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/Message.cs @@ -1,24 +1,3 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// /****************************************************************************** * The MIT License * Copyright (c) 2003 Novell Inc. www.novell.com @@ -494,6 +473,7 @@ namespace Novell.Directory.Ldap case LdapMessage.SEARCH_RESPONSE: case LdapMessage.SEARCH_RESULT_REFERENCE: + case LdapMessage.INTERMEDIATE_RESPONSE: break; default: diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs index 40e3c61fff5..cdbdb8ac427 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/MessageVector.cs @@ -1,24 +1,3 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// /****************************************************************************** * The MIT License * Copyright (c) 2003 Novell Inc. www.novell.com |