Пример #1
0
        internal Byte[] TryEncodePacket(LdapMessage message)
        {
            OperationMapper mapper  = SingletonContainer.GetOperationMapper();
            Type            encoder = mapper.GetEncoderForTag(message.ProtocolOp.GetTag());

            AsnWriter writer = new AsnWriter(AsnEncodingRules.BER);

            object?result = null;

            using (writer.PushSequence())
            {
                writer.WriteInteger(message.MessageId);

                var    parameters     = new object[] { writer, message.ProtocolOp };
                object?invokableClass = FormatterServices.GetUninitializedObject(encoder);

                if (invokableClass != null)
                {
                    MethodInfo?method = encoder.GetMethod("TryEncode");
                    if (method != null)
                    {
                        result = method.Invoke(invokableClass, parameters);
                    }
                }
            }

            if (result != null)
            {
                Byte[] data = writer.Encode();
                return(data);
            }

            throw new NotImplementedException("The encoder for " + message.ProtocolOp.GetTag() + " is not implemented.");
        }
Пример #2
0
        private static LdapEntry GetOneUserEntry(
            LdapConnection conn,
            LdapSettings ldapSettings,
            string search)
        {
            LdapSearchConstraints constraints = new LdapSearchConstraints();

            LdapSearchQueue queue = null;

            queue = conn.Search(
                ldapSettings.RootDN,
                LdapConnection.SCOPE_SUB,
                ldapSettings.UserDNKey + "=" + search,
                null,
                false,
                (LdapSearchQueue)null,
                (LdapSearchConstraints)null);

            LdapEntry entry = null;

            if (queue != null)
            {
                LdapMessage message = queue.getResponse();
                if (message != null)
                {
                    if (message is LdapSearchResult)
                    {
                        entry = ((LdapSearchResult)message).Entry;
                    }
                }
            }

            return(entry);
        }
            private void Run()
            {
                while (_isrunning)
                {
                    LdapMessage response = null;
                    try
                    {
                        while (_isrunning &&
                               !_searchqueue.IsResponseReceived(_messageid))
                        {
                            Thread.Sleep(SleepTime);
                        }

                        if (_isrunning)
                        {
                            response = _searchqueue.GetResponse(_messageid);
                        }

                        if (response != null)
                        {
                            Processmessage(response);
                        }
                    }
                    catch (LdapException e)
                    {
                        _mObjLdapEventSource.NotifyExceptionListeners(response, e);
                    }
                }
            } // end of method run
Пример #4
0
 public DirectoryEventArgs(
     LdapMessage sourceMessage,
     EventClassifiers aClassification)
     : base(sourceMessage)
 {
     EClassification = aClassification;
 }
 public SearchResultEventArgs(
     LdapMessage sourceMessage,
     EventClassifiers aClassification,
     LdapEventType aType)
     : base(sourceMessage, EventClassifiers.ClassificationLdapPsearch, aType)
 {
 }
            } // end of method run

            private void Processmessage(LdapMessage response)
            {
                if (response is LdapResponse)
                {
                    try
                    {
                        ((LdapResponse)response).ChkResultCode();

                        _mObjLdapEventSource.NotifyEventListeners(
                            response,
                            EventClassifiers.ClassificationUnknown,
                            EventTypeUnknown);
                    }
                    catch (LdapException e)
                    {
                        _mObjLdapEventSource.NotifyExceptionListeners(response, e);
                    }
                }
                else
                {
                    _mObjLdapEventSource.NotifyEventListeners(
                        response,
                        EventClassifiers.ClassificationUnknown,
                        EventTypeUnknown);
                }
            } // end of method processmessage
Пример #7
0
        public static int CheckLdapTimedOut(string sDN, string sRootDN)
        {
            int              ret        = -1;
            LdapMessage      message    = null;
            DirectoryContext dircontext = null;

            if (exisitngDirContext != null && exisitngDirContext.Count > 0)
            {
                foreach (DirectoryContext context in exisitngDirContext)
                {
                    if (context.DomainName.Equals(sRootDN, StringComparison.InvariantCultureIgnoreCase))
                    {
                        dircontext = context;
                    }
                }
            }

            ret = dircontext.SearchSynchronous(
                sDN,
                Likewise.LMC.LDAP.Interop.LdapAPI.LDAPSCOPE.BASE,
                "(objectClass=*)",
                new string[]
            {
                "objectClass", "distinguishedName", null
            },
                false,
                out message);

            return(ret);
        }
Пример #8
0
            } // end of Constructor

            protected void Run()
            {
                while (isrunning)
                {
                    LdapMessage response = null;
                    try
                    {
                        while (isrunning
                               && !searchqueue.isResponseReceived(messageid))
                        {
                            Thread.Sleep(sleep_time);
                        }

                        if (isrunning)
                        {
                            response = searchqueue.getResponse(messageid);
                        }

                        if (response != null)
                        {
                            processmessage(response);
                        }
                    }
                    catch (LdapException e)
                    {
                        m_objLdapEventSource.NotifyExceptionListeners(response, e);
                    }
                }
            } // end of method run
Пример #9
0
 protected void NotifyExceptionListeners(LdapMessage sourceMessage, LdapException ldapException)
 {
     if (null != directory_exception_event)
     {
         directory_exception_event(this, new DirectoryExceptionEventArgs(sourceMessage, ldapException));
     }
 }
Пример #10
0
 public SearchReferralEventArgs(LdapMessage sourceMessage,
                                EventClassifiers aClassification,
                                LdapEventType aType)
     : base(sourceMessage, EventClassifiers.CLASSIFICATION_LDAP_PSEARCH,
            LdapEventType.LDAP_PSEARCH_ANY) // TODO: why type is ANY..?
 {
 }
        // TODO: why type is ANY..?
        public SearchReferralEventArgs(LdapMessage sourceMessage,
            EventClassifiers aClassification,
            LdapEventType aType)
            : base(sourceMessage, EventClassifiers.CLASSIFICATION_LDAP_PSEARCH, 
	     LdapEventType.LDAP_PSEARCH_ANY)
        {
        }
Пример #12
0
 public SearchReferralEventArgs(
     LdapMessage sourceMessage,
     EventClassifiers aClassification,
     LdapEventType aType)
     : base(sourceMessage, EventClassifiers.ClassificationLdapPsearch,
            LdapEventType.LdapPsearchAny) // TODO: why type is ANY..?
 {
 }
Пример #13
0
 public LdapEventArgs(
     LdapMessage sourceMessage,
     EventClassifiers aClassification,
     LdapEventType aType)
     : base(sourceMessage, aClassification)
 {
     eType = aType;
 }
Пример #14
0
    public LdapEventArgs(
		     LdapMessage sourceMessage,
		     EventClassifiers aClassification,
		     LdapEventType aType)
      : base(sourceMessage, aClassification)
    {
      eType = aType;
    }
Пример #15
0
        //return an array of ldapPath strings
        public List <string> FindAllChild(string filter, SearchScope searchScope, string[] propertiesToLoad)
        {
            Assign_dirContext();

            if (dirContext == null)
            {
                return(null);
            }

            if (!get_baseDnFor_guidOrsid_called)
            {
                Get_baseDn_Guid_Or_sid();
            }

            LdapAPI.LDAPSCOPE ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL;

            if (searchScope == SearchScope.Base)
            {
                ldapscope = LdapAPI.LDAPSCOPE.BASE;
            }
            else if (searchScope == SearchScope.OneLevel)
            {
                ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL;
            }
            else if (searchScope == SearchScope.Subtree)
            {
                ldapscope = LdapAPI.LDAPSCOPE.SUB_TREE;
            }

            LdapMessage ldapMessage = dirContext.SearchSynchronous(
                baseDn,
                ldapscope,
                filter,
                //new string[] { "distinguishedName", null },
                Getsearch_attrs(propertiesToLoad),
                false);

            List <LdapEntry> ldapEntries = (ldapMessage != null ? ldapMessage.Ldap_Get_Entries() : null);

            if (ldapEntries != null && ldapEntries.Count > 0)
            {
                ldapPaths = new List <string>();

                foreach (LdapEntry entry in ldapEntries)
                {
                    Thread thread = new Thread(new ParameterizedThreadStart(GetObjectLdapPath));
                    thread.Start(entry);
                    thread.Join();
                }

                return(ldapPaths);
            }

            return(null);
        }
Пример #16
0
        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);
            }
        }
Пример #17
0
        //find the DN of given the sid
        public static string SearchBySid(string sid, Likewise.LMC.LDAP.DirectoryContext dirContext)
        {
            string searchFilter = string.Concat("(objectSid=", sid, ")");

            LdapMessage ldapMessage = dirContext.SearchSynchronous(
                dirContext.RootDN,
                LdapAPI.LDAPSCOPE.SUB_TREE,
                searchFilter,
                null,
                false);

            if (ldapMessage == null)
            {
                // Logger.Log("ldapMessage = null");
                return(null);
            }
            else
            {
                List <LdapEntry> ldapEntries = ldapMessage.Ldap_Get_Entries();
                if (ldapEntries == null || ldapEntries.Count == 0)
                {
                    // Logger.Log("ldapEntries.Count == 0");
                    return(null);
                }

                LdapEntry ldapNextEntry = ldapEntries[0];

                if (ldapNextEntry != null)
                {
                    string[] attrsList = ldapNextEntry.GetAttributeNames();

                    if (attrsList != null)
                    {
                        foreach (string attr in attrsList)
                        {
                            if (attr.Equals("distinguishedName", StringComparison.InvariantCultureIgnoreCase))
                            {
                                LdapValue[] attrValues = ldapNextEntry.GetAttributeValues(attr, dirContext);

                                if (attrValues != null && attrValues.Length > 0)
                                {
                                    return(attrValues[0].stringData);
                                }
                            }
                        }
                    }
                }
                return(null);
            }
        }
Пример #18
0
        //this function will return a ldapMessage that contains all the attributes that are available for an object
        //use this to populate DirectoryEntry's properties
        public static List <string> InitLdapMessageFilterForProperties(Likewise.LMC.LDAP.DirectoryContext dirContext, string nodeDN)
        {
            LdapMessage ldapMessagetemp = null;

            string[] attrs = { "name", "allowedAttributes", null };

            if (ldapMessagetemp == null)
            {
                ldapMessagetemp = dirContext.SearchSynchronous(
                    nodeDN,
                    LdapAPI.LDAPSCOPE.BASE,
                    "(objectClass=*)",
                    attrs,
                    false);
            }

            if (ldapMessagetemp == null)
            {
                return(null);
            }

            List <LdapEntry> ldapEntries = ldapMessagetemp.Ldap_Get_Entries();

            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                return(null);
            }

            LdapEntry ldapNextEntry = ldapEntries[0];

            List <string> allowedAttributes = new List <string>();

            LdapValue[] attrValues = ldapNextEntry.GetAttributeValues("allowedAttributes", dirContext);
            if (attrValues != null && attrValues.Length > 0)
            {
                foreach (LdapValue attrValue in attrValues)
                {
                    allowedAttributes.Add(attrValue.stringData);
                }
            }

            return(allowedAttributes);
        }
Пример #19
0
        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);
        }
Пример #20
0
            } // 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)
                            {
                                LogManager.GetLogger(typeof(EventsGenerator)).
                                DebugFormat("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
Пример #21
0
            } // 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
Пример #22
0
        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;
        }
Пример #23
0
        public void CommitChanges()
        {
            Assign_dirContext();

            if (dirContext == null)
            {
                return;
            }

            if (!get_baseDnFor_guidOrsid_called)
            {
                Get_baseDn_Guid_Or_sid();
            }

            string[]    search_attrs = { null };
            LdapMessage ldapMessage  = dirContext.SearchSynchronous(
                baseDn,
                LdapAPI.LDAPSCOPE.BASE,
                "(objectClass=*)",
                search_attrs,
                false);
            List <LdapEntry> ldapEntries = (ldapMessage != null ? ldapMessage.Ldap_Get_Entries() : null);

            //if this object does not exist in AD, we need create it first
            if (ldapEntries == null || ldapEntries.Count == 0)
            {
                int ret = SDSUtils.AddNewObj(dirContext, objectClassType, baseDn);
                if (ret != 0)
                {
                    //Console.WriteLine("Create new object failed!");
                    return;
                }
            }

            //go through the properties to check whether there is PropertyValueCollection has been modified
            //PropertyCollection: Dictionary<string, PropertyValueCollection>
            if (propertyCollection != null && propertyCollection.Count > 0)
            {
                foreach (KeyValuePair <string, PropertyValueCollection> kvp in propertyCollection)
                {
                    if (kvp.Value.Modified)
                    {
                        //Console.WriteLine("BaseDN is " + baseDn + " Modified key value pair: " + kvp.Key );
                        int ret = SDSUtils.ModifyProperty(dirContext, baseDn, kvp.Key, kvp.Value);
                        //if (ret != 0) ; Console.WriteLine("Modify a property failed");
                    }
                }
            }

            //go through its children to see whether this is any children marked needed be deleted
            if (children != null && children.Count > 0)
            {
                DirectoryEntries modifiedChildren = new DirectoryEntries();

                foreach (DirectoryEntry child in children)
                {
                    if (child.ToBeDeleted) //delete this DE
                    {
                        int ret = SDSUtils.DeleteObj(dirContext, child.Name);
                    }
                }

                //reflect the changes to children collection
                foreach (DirectoryEntry child in children)
                {
                    if (!child.ToBeDeleted)
                    {
                        modifiedChildren.Add(child);
                    }
                }

                children = modifiedChildren;
            }
        }
Пример #24
0
 NotifyEventListeners(LdapMessage sourceMessage,
                      EventClassifiers aClassification,
                      int nType);
Пример #25
0
 protected void NotifyDirectoryListeners(LdapMessage sourceMessage,
                                         EventClassifiers aClassification)
 {
     NotifyDirectoryListeners(new DirectoryEventArgs(sourceMessage,
                                                     aClassification));
 }
 public SearchResultEventArgs(LdapMessage sourceMessage,
                              EventClassifiers aClassification,
                              LdapEventType aType)
     : base(sourceMessage, EventClassifiers.CLASSIFICATION_LDAP_PSEARCH, aType)
 {
 }
Пример #27
0
 public DirectoryExceptionEventArgs(LdapMessage message, LdapException ldapException)
     : base(message)
 {
     ldap_exception_object = ldapException;
 }
Пример #28
0
 public BaseEventArgs(LdapMessage message)
 {
   ldap_message = message;
 }
Пример #29
0
        } // end of method StopEventPolling

        protected abstract bool NotifyEventListeners(LdapMessage sourceMessage, EventClassifiers aClassification, int nType);
Пример #30
0
 public EdirEventArgs(LdapMessage sourceMessage,
                      EventClassifiers aClassification)
     : base(sourceMessage, aClassification)
 {
 }
Пример #31
0
        //return the found entry's LdapPath
        public string FindFirstChild(string filter, SearchScope searchScope, string[] propertiesToLoad)
        {
            Assign_dirContext();

            if (dirContext == null)
            {
                return(null);
            }

            if (!get_baseDnFor_guidOrsid_called)
            {
                Get_baseDn_Guid_Or_sid();
            }

            LdapAPI.LDAPSCOPE ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL;

            if (searchScope == SearchScope.Base)
            {
                ldapscope = LdapAPI.LDAPSCOPE.BASE;
            }
            else if (searchScope == SearchScope.OneLevel)
            {
                ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL;
            }
            else if (searchScope == SearchScope.Subtree)
            {
                ldapscope = LdapAPI.LDAPSCOPE.SUB_TREE;
            }

            LdapMessage ldapMessage = dirContext.SearchSynchronous(
                baseDn,
                ldapscope,
                filter,
                //new string[] { "distinguishedName", null },
                Getsearch_attrs(propertiesToLoad),
                false);

            List <LdapEntry> ldapEntries = (ldapMessage != null ? ldapMessage.Ldap_Get_Entries() : null);

            if (ldapEntries != null && ldapEntries.Count > 0)
            {
                LdapEntry entry = ldapEntries[0];

                string[] attrsList = entry.GetAttributeNames();

                if (attrsList != null && attrsList.Length > 0)
                {
                    if (entry != null)
                    {
                        LdapValue[] values = entry.GetAttributeValues("distinguishedName", dirContext);
                        if (values != null && values.Length > 0)
                        {
                            return(string.Concat("LDAP://", sServer, "/", values[0].stringData));
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }

            return(null);
        }
Пример #32
0
        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;
        }
Пример #33
0
    public DirectoryEventArgs(LdapMessage sourceMessage,
			      EventClassifiers aClassification)
      : base(sourceMessage)
    {
      eClassification = aClassification;
    }
Пример #34
0
        protected override bool NotifyEventListeners(
            LdapMessage sourceMessage,
            EventClassifiers aClassification,
            int nType)
        {
            var bListenersNotified = false;

            if (sourceMessage == null)
            {
                return(bListenersNotified);
            }

            switch (sourceMessage.Type)
            {
            case LdapMessage.SearchResultReference:
                if (_searchReferralEvent != null)
                {
                    _searchReferralEvent(
                        this,
                        new SearchReferralEventArgs(
                            sourceMessage,
                            aClassification,
                            (LdapEventType)nType));
                    bListenersNotified = true;
                }

                break;

            case LdapMessage.SearchResponse:
                if (_searchResultEvent != null)
                {
                    var changeType = LdapEventType.TypeUnknown;
                    var controls   = sourceMessage.Controls;
                    foreach (var 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..?
                        }
                    }

                    // if no changeType then value is TYPE_UNKNOWN
                    _searchResultEvent(
                        this,
                        new SearchResultEventArgs(
                            sourceMessage,
                            aClassification,
                            changeType));
                    bListenersNotified = true;
                }

                break;

            case LdapMessage.SearchResult:
                // This is a generic LDAP Event
                // TODO: Why the type is ANY...? (java code)
                NotifyDirectoryListeners(new LdapEventArgs(
                                             sourceMessage,
                                             EventClassifiers.ClassificationLdapPsearch,
                                             LdapEventType.LdapPsearchAny));
                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);
        }
 public DirectoryExceptionEventArgs(LdapMessage message, LdapException ldapException)
     : base(message)
 {
     ldap_exception_object = ldapException;
 }
Пример #36
0
 public BaseEventArgs(LdapMessage message)
 {
     ldap_message = message;
 }
Пример #37
0
        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);
        }
Пример #38
0
 public EdirEventArgs(LdapMessage sourceMessage,
     EventClassifiers aClassification)
     : base(sourceMessage, aClassification)
 {
 }