Beispiel #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MimeKit.MailboxAddress"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="MailboxAddress"/> with the specified name, address and route. The
		/// specified text encoding is used when encoding the name according to the rules of rfc2047.
		/// </remarks>
		/// <param name="encoding">The character encoding to be used for encoding the name.</param>
		/// <param name="name">The name of the mailbox.</param>
		/// <param name="route">The route of the mailbox.</param>
		/// <param name="address">The address of the mailbox.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <para><paramref name="encoding"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="route"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="address"/> is <c>null</c>.</para>
		/// </exception>
		public MailboxAddress (Encoding encoding, string name, IEnumerable<string> route, string address) : base (encoding, name)
		{
			if (address == null)
				throw new ArgumentNullException ("address");

			Route = new DomainList (route);
			Route.Changed += RouteChanged;
			Address = address;
		}
		public void TestBasicListFunctionality ()
		{
			var list = new DomainList ();

			Assert.IsFalse (list.IsReadOnly);
			Assert.AreEqual (0, list.Count, "Initial count");

			list.Add ("domain2");

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain2", list[0]);

			list.Insert (0, "domain0");
			list.Insert (1, "domain1");

			Assert.AreEqual (3, list.Count);
			Assert.AreEqual ("domain0", list[0]);
			Assert.AreEqual ("domain1", list[1]);
			Assert.AreEqual ("domain2", list[2]);

			Assert.IsTrue (list.Contains ("domain1"), "Contains");
			Assert.AreEqual (1, list.IndexOf ("domain1"), "IndexOf");

			var array = new string[list.Count];
			list.CopyTo (array, 0);
			list.Clear ();

			Assert.AreEqual (0, list.Count);

			foreach (var domain in array)
				list.Add (domain);

			Assert.AreEqual (array.Length, list.Count);

			Assert.IsTrue (list.Remove ("domain2"));
			Assert.AreEqual (2, list.Count);
			Assert.AreEqual ("domain0", list[0]);
			Assert.AreEqual ("domain1", list[1]);

			list.RemoveAt (0);

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain1", list[0]);

			list[0] = "domain";

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain", list[0]);
		}
Beispiel #3
0
		static void AssertParse (string text, DomainList expected)
		{
			DomainList route;
			int index = 0;

			Assert.IsTrue (DomainList.TryParse (text, out route), "DomainList.TryParse(string)");
			Assert.IsFalse (route.IsReadOnly, "IsReadOnly");
			Assert.AreEqual (expected.Count, route.Count, "Count");

			foreach (var domain in expected) {
				Assert.AreEqual (index, route.IndexOf (domain), "IndexOf");
				Assert.IsTrue (route.Contains (domain), "Contains");
				Assert.AreEqual (expected[index], route[index]);
				index++;
			}
		}
		public void TestArgumentExceptions ()
		{
			var list = new DomainList ();

			Assert.Throws<ArgumentNullException> (() => new DomainList (null));
			Assert.Throws<ArgumentNullException> (() => list.Add (null));
			Assert.Throws<ArgumentNullException> (() => list.Contains (null));
			Assert.Throws<ArgumentNullException> (() => list.CopyTo (null, 0));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.CopyTo (new string[0], -1));
			Assert.Throws<ArgumentNullException> (() => list.IndexOf (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.Insert (-1, "item"));
			Assert.Throws<ArgumentNullException> (() => list.Insert (0, null));
			Assert.Throws<ArgumentNullException> (() => list[0] = null);
			Assert.Throws<ArgumentNullException> (() => list.Remove (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.RemoveAt (-1));
		}
        /// <summary>
        /// Finds a TypedEntity based on the Uri
        /// </summary>
        /// <param name="fullUrlIncludingDomain"></param>
        /// <param name="revisionStatusType"></param>
        /// <returns></returns>
        public EntityRouteResult FindEntityByUrl(Uri fullUrlIncludingDomain, RevisionStatusType revisionStatusType)
        {
            Mandate.ParameterNotNull(fullUrlIncludingDomain.Scheme, "Scheme");

            //cache key is full uri except query string and revision status
            var cacheKey = EntityMappedKey + "-" + fullUrlIncludingDomain.GetLeftPart(UriPartial.Path) + "-" + revisionStatusType;

            //TODO: We need to change how the NiceUrls are cached because if we store them in one entry as a dictionary in cache, then
            // we can do a reverse lookup to see if we've already generated the URL for the entity which may match the fullUrlIncludingDomain,
            // if so, then all we have to do is return the entity with the cached ID.

            return(ApplicationContext.FrameworkContext.ApplicationCache
                   .GetOrCreate(cacheKey, () =>
            {
                using (DisposableTimer.Start(timer =>
                                             LogHelper.TraceIfEnabled <DefaultRoutingEngine>("FindEntityByUrl for URL {0} took {1}ms", () => fullUrlIncludingDomain, () => timer)))
                {
                    var persistenceManager = ApplicationContext.Hive.GetReader <IContentStore>(fullUrlIncludingDomain);
                    if (persistenceManager != null)
                    {
                        using (var uow = persistenceManager.CreateReadonly())
                        {
                            //first, lets check if it's an ID URL
                            var path = fullUrlIncludingDomain.AbsolutePath.Substring(
                                _httpContext.Request.ApplicationPath.TrimEnd('/').Length,
                                fullUrlIncludingDomain.AbsolutePath.Length - _httpContext.Request.ApplicationPath.TrimEnd('/').Length);
                            var urlId = HiveId.TryParse(path.TrimStart('/'));
                            if (urlId.Success && urlId.Result.ProviderGroupRoot != null)
                            {
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("Resolving entity by Id URL (Id: {0} ", () => urlId.Result.ToFriendlyString());
                                try
                                {
                                    var entityById = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(urlId.Result, revisionStatusType);
                                    if (entityById == null)
                                    {
                                        LogHelper.Warn <DefaultRoutingEngine>("Resolving entity by Id URL failed (Id: {0} ", urlId.Result.ToFriendlyString());
                                        return null;
                                    }
                                    return new HttpRuntimeCacheParameters <EntityRouteResult>(
                                        new EntityRouteResult(entityById.Item, EntityRouteStatus.SuccessById));
                                }
                                catch (ArgumentException)
                                {
                                    //this occurs if the Id parsed but 'not really'
                                    return null;
                                }
                            }

                            Revision <TypedEntity> lastRevisionFound;
                            TypedEntity lastItemFound;
                            //is the current requesting hostname/port in our list ?
                            if (DomainList.ContainsHostname(fullUrlIncludingDomain.Authority))
                            {
                                //domain found so get the first item assigned to this domain
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("Resolving entity by Domain URL");
                                var hostnameEntry = DomainList[fullUrlIncludingDomain.Authority];
                                lastRevisionFound = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(hostnameEntry.ContentId, revisionStatusType);
                                Mandate.That(lastRevisionFound != null, x => new InvalidOperationException("Could not find an entity with a revision status of '" + revisionStatusType.Alias + "', having a hostname '" + fullUrlIncludingDomain.Authority + "' and id: " + hostnameEntry.ContentId));
                                lastItemFound = lastRevisionFound.Item;
                            }
                            else
                            {
                                //no domain found for the current request, so we need to find the first routable node that doesn't require a domain
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("Resolving entity by Non-Domain URL");
                                //var root = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(FixedHiveIds.ContentVirtualRoot, revisionStatusType);
                                //Mandate.That(root != null, x => new InvalidOperationException("Could not find the content root"));
                                var domainListIds = DomainList.Select(d => d.ContentId);

                                var firstLevelRelations =
                                    uow.Repositories.GetChildRelations(FixedHiveIds.ContentVirtualRoot, FixedRelationTypes.DefaultRelationType).OrderBy(
                                        x => x.Ordinal).ToArray();

                                //try to find a first level node that doesn't exist in our domain list
                                var firstNonHostnameEntity = firstLevelRelations.FirstOrDefault(x => !domainListIds.Contains(x.DestinationId));

                                //if there is no first level node anywhere, then there is no content. Show a friendly message
                                if (firstNonHostnameEntity == null && firstLevelRelations.Count() == 0)
                                {
                                    return null;
                                }

                                //if we have a first level node not assigned to a domain, use the first, otherwise if all nodes are assigned to domains, then just use the first
                                lastRevisionFound = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(
                                    firstNonHostnameEntity == null
                                                ? firstLevelRelations.First().DestinationId
                                                : firstNonHostnameEntity.DestinationId, revisionStatusType);

                                lastItemFound = lastRevisionFound != null ? lastRevisionFound.Item : null;
                            }


                            // Now we will have the path from the current application root like:
                            //      /this/is/a/path/to/a/document
                            // Now we need to walk down the tree
                            if (lastItemFound != null && !string.IsNullOrWhiteSpace(path) && path != "/")
                            {
                                lastItemFound = uow.Repositories.GetEntityByPath <TypedEntity>(lastItemFound.Id, path, revisionStatusType, true);
                            }

                            if (lastItemFound == null)
                            {
                                return new HttpRuntimeCacheParameters <EntityRouteResult>(
                                    new EntityRouteResult(null, EntityRouteStatus.FailedNotFoundByName));
                            }

                            return new HttpRuntimeCacheParameters <EntityRouteResult>(
                                new EntityRouteResult(lastItemFound, EntityRouteStatus.SuccessWithoutHostname));
                        }
                    }

                    return null;
                }
            }));
        }
Beispiel #6
0
        static void AssertParseFailure(string text)
        {
            DomainList route;

            Assert.IsFalse(DomainList.TryParse(text, out route), "DomainList.TryParse(string)");
        }
Beispiel #7
0
        public void TestParseEmptyDomains()
        {
            var expected = new DomainList(new [] { "domain1", "domain2" });

            AssertParse("@domain1,,@domain2", expected);
        }
Beispiel #8
0
        private void UserMap()
        {
            ScheduleViewModel scheduleViewModel =
                ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);
            bool bCSV = false;

            Microsoft.Win32.OpenFileDialog fDialog = new Microsoft.Win32.OpenFileDialog();
            fDialog.Filter          = "User Map Files|*.xml;*.csv";
            fDialog.CheckFileExists = true;
            fDialog.Multiselect     = false;
            if (fDialog.ShowDialog() == true)
            {
                int lastDot = fDialog.FileName.LastIndexOf(".");

                if (lastDot != -1)
                {
                    string substr = fDialog.FileName.Substring(lastDot, 4);

                    if (substr == ".csv")
                    {
                        bCSV = true;

                        /*try
                        * {
                        *  string names = File.ReadAllText(fDialog.FileName);
                        *  string[] nameTokens = names.Split(',');
                        *  foreach (string name in nameTokens)
                        *  {
                        *      UsersList.Add(name);
                        *      scheduleViewModel.SchedList.Add(name);
                        *  }
                        * }
                        * catch (IOException ex)
                        * {
                        *  MessageBox.Show(ex.Message, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        * }*/
                        List <string[]> parsedData = new List <string[]>();
                        try
                        {
                            if (File.Exists(fDialog.FileName))
                            {
                                using (StreamReader readFile = new StreamReader(fDialog.FileName)) {
                                    string line;

                                    string[] row;
                                    while ((line = readFile.ReadLine()) != null)
                                    {
                                        row = line.Split(',');
                                        parsedData.Add(row);
                                    }
                                    readFile.Close();
                                }
                            }
                            else
                            {
                                MessageBox.Show(
                                    "There is no user information stored.Please enter some user info",
                                    "Zimbra Migration", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                            }
                        }
                        catch (Exception e)
                        {
                            string message = e.Message;
                        }
                        // for (int i = 1; i < parsedData.Count; i++)
                        {
                            string[] strres = new string[parsedData.Count];

                            Users tempuser = new Users();

                            try
                            {
                                for (int j = 0; j < parsedData.Count; j++)
                                {
                                    bool bFoundSharp = false;
                                    strres = parsedData[j];
                                    int num = strres.Count();
                                    for (int k = 0; k < num; k++)
                                    {
                                        if (strres[k].Contains("#"))
                                        {
                                            bFoundSharp = true;
                                            break;
                                        }
                                    }
                                    if (!bFoundSharp) // FBS bug 71933 -- 3/21/12
                                    {
                                        tempuser.UserName   = strres[0];
                                        tempuser.MappedName = strres[1];

                                        tempuser.ChangePWD = Convert.ToBoolean(strres[2]);
                                        // tempuser.PWDdefault = strres[3];
                                        // string result = tempuser.UserName + "," + tempuser.MappedName +"," + tempuser.ChangePWD + "," + tempuser.PWDdefault;
                                        string result = tempuser.Username + "," + tempuser.MappedName;

                                        Username   = strres[0];
                                        MappedName = strres[1];
                                        UsersViewModel uvm = new UsersViewModel(Username, MappedName);
                                        uvm.MustChangePassword = tempuser.ChangePWD;
                                        UsersList.Add(uvm);
                                        scheduleViewModel.SchedList.Add(new SchedUser(Username, false));
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Incorrect .csv file format", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }

                            EnableNext = (UsersList.Count > 0);
                        }
                        scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedList.Count > 0);
                        scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;

                        // /
                        // Domain information is stored in the xml and not in  the usermap.
                        // will have to revisit

                        System.Xml.Serialization.XmlSerializer reader =
                            new System.Xml.Serialization.XmlSerializer(typeof(Config));
                        if (File.Exists(scheduleViewModel.GetConfigFile()))
                        {
                            System.IO.StreamReader fileRead = new System.IO.StreamReader(
                                scheduleViewModel.GetConfigFile());

                            Config Z11 = new Config();

                            Z11 = (Config)reader.Deserialize(fileRead);
                            fileRead.Close();
                            ZimbraDomain = Z11.UserProvision.DestinationDomain;
                            if (DomainList.Count > 0)
                            {
                                CurrentDomainSelection = (ZimbraDomain == null) ? 0 :
                                                         DomainList.IndexOf(ZimbraDomain);
                            }

                            else
                            {
                                DomainList.Add(ZimbraDomain);
                            }
                        }
                        scheduleViewModel.SetUsermapFile(fDialog.FileName);
                    }
                }
                if (!bCSV)
                {
                    MessageBox.Show("Only CSV files are supported", "Zimbra Migration",
                                    MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
Beispiel #9
0
        public bool ExecuteSamrDetection()
        {
            try
            {
                var sensitiveGroupList = DbClient.GetSensitiveGroups();

                foreach (var coupledSamr in SamrCouples)
                {
                    var domainController = DomainControllers.First(_ =>
                                                                   _.Domain == DomainList.Single(__ => __.Id == coupledSamr.Machine.Domain).Id);

                    if (coupledSamr.RatingType.ToLower() == "low")
                    {
                        var administratorObject = Users.First(_ => _.Name == "Administrator");

                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway));
                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway,
                                                                           $"{(Spn) _random.Next(0, 5)}/{DomainControllers.FirstOrDefault()?.Name}", null, "Tgs", 0,
                                                                           0, ActivitiesList.Last()["_id"].AsObjectId));
                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway,
                                                                           $"{(Spn) _random.Next(0, 5)}/{DomainControllers.FirstOrDefault()?.Name}", null, "Ap", 0,
                                                                           0, ActivitiesList.Last()["_id"].AsObjectId));
                        ActivitiesList.Add(DocumentCreator.SamrCreator(coupledSamr.User, coupledSamr.Machine,
                                                                       domainController,
                                                                       DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                       , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway, true,
                                                                       SamrQueryType.QueryUser, SamrQueryOperation.QueryInformationUser,
                                                                       DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Id, 0,
                                                                       administratorObject));
                    }
                    else
                    {
                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway));
                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway,
                                                                           $"{(Spn)_random.Next(0, 5)}/{DomainControllers.FirstOrDefault()?.Name}", null, "Tgs", 0,
                                                                           0, ActivitiesList.Last()["_id"].AsObjectId));
                        ActivitiesList.Add(DocumentCreator.KerberosCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController, DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway,
                                                                           $"{(Spn)_random.Next(0, 5)}/{DomainControllers.FirstOrDefault()?.Name}", null, "Ap", 0,
                                                                           0, ActivitiesList.Last()["_id"].AsObjectId));

                        foreach (var group in sensitiveGroupList)
                        {
                            ActivitiesList.Add(DocumentCreator.SamrCreator(coupledSamr.User, coupledSamr.Machine,
                                                                           domainController,
                                                                           DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                           , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway, true,
                                                                           SamrQueryType.QueryGroup, SamrQueryOperation.QueryInformationGroup,
                                                                           DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Id, 0,
                                                                           group));
                        }
                    }
                }
                InsertActivities();
                return(true);
            }
            catch (Exception e)
            {
                Logger.Debug(e);
                return(false);
            }
        }
Beispiel #10
0
 private void DelDomainButton_Click(object sender, EventArgs e)
 {
     statusLabel.Text = "Le domaine \"" + ((Domain)DomainListbox.SelectedValue).Name + "\" a été supprimé";
     DomainList.Remove(DomainList[DomainListbox.SelectedIndex]);
     UnsavedModifications = true;
 }
Beispiel #11
0
        /// <summary>
        /// Finds a TypedEntity based on the Uri
        /// </summary>
        /// <param name="fullUrlIncludingDomain"></param>
        /// <param name="revisionStatusType"></param>
        /// <returns></returns>
        public EntityRouteResult FindEntityByUrl(Uri fullUrlIncludingDomain, RevisionStatusType revisionStatusType = null)
        {
            Mandate.ParameterNotNull(fullUrlIncludingDomain.Scheme, "Scheme");

            var statusTypeCacheKey = (revisionStatusType != null) ? revisionStatusType.Alias : string.Empty;

            //cache key is full uri except query string and revision status
            var cacheKey = EntityMappedKey + "-" + fullUrlIncludingDomain.GetLeftPart(UriPartial.Path) + "-" + statusTypeCacheKey;

            //TODO: We need to change how the NiceUrls are cached because if we store them in one entry as a dictionary in cache, then
            // we can do a reverse lookup to see if we've already generated the URL for the entity which may match the fullUrlIncludingDomain,
            // if so, then all we have to do is return the entity with the cached ID.

            return(ApplicationContext.FrameworkContext.ApplicationCache
                   .GetOrCreate(cacheKey, () =>
            {
                using (DisposableTimer.Start(timer =>
                                             LogHelper.TraceIfEnabled <DefaultRoutingEngine>("FindEntityByUrl (not from cache) for URL {0} took {1}ms", () => fullUrlIncludingDomain, () => timer)))
                {
                    ReadonlyGroupUnitFactory <IContentStore> persistenceManager;

                    using (DisposableTimer.TraceDuration <DefaultRoutingEngine>("FindEntityByUrl: Getting a reader", "FindEntityByUrl: Got a reader"))
                        persistenceManager = ApplicationContext.Hive.GetReader <IContentStore>(fullUrlIncludingDomain);

                    if (persistenceManager != null)
                    {
                        IReadonlyGroupUnit <IContentStore> readonlyGroupUnit;
                        using (DisposableTimer.TraceDuration <DefaultRoutingEngine>("FindEntityByUrl: Opening a reader", "FindEntityByUrl: Opened a reader"))
                            readonlyGroupUnit = persistenceManager.CreateReadonly();

                        using (var uow = readonlyGroupUnit)
                        {
                            //first, lets check if it's an ID URL
                            var trimmedAppPath = _httpContext.Request.ApplicationPath.TrimEnd('/');
                            var appPathLength = trimmedAppPath.Length;

                            // gate-check for the incoming url because some code (e.g. the alt-template checker) could be unaware of vdirs etc.
                            var absolutePath = fullUrlIncludingDomain.AbsolutePath;
                            var path = (absolutePath.Length < appPathLength) ? absolutePath : absolutePath.Substring(appPathLength, absolutePath.Length - appPathLength);

                            var urlId = HiveId.TryParse(path.TrimStart('/'));
                            if (urlId.Success && urlId.Result.ProviderGroupRoot != null)
                            {
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("In FindEntityByUrl: Resolving entity by Id URL (Id: {0} ", () => urlId.Result.ToFriendlyString());
                                try
                                {
                                    //var entityById = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(urlId.Result, revisionStatusType);
                                    var entityById = uow.Repositories.OfRevisionType(revisionStatusType).InIds(urlId.Result.AsEnumerableOfOne()).FirstOrDefault();
                                    if (entityById == null)
                                    {
                                        LogHelper.Warn <DefaultRoutingEngine>("In FindEntityByUrl: Resolving entity by Id URL failed (Id: {0} ", urlId.Result.ToFriendlyString());
                                        return null;
                                    }
                                    return new HttpRuntimeCacheParameters <EntityRouteResult>(new EntityRouteResult(entityById, EntityRouteStatus.SuccessById));
                                }
                                catch (ArgumentException)
                                {
                                    //this occurs if the Id parsed but 'not really'
                                    return null;
                                }
                            }

                            TypedEntity lastItemFound;
                            //is the current requesting hostname/port in our list ?
                            if (DomainList.ContainsHostname(fullUrlIncludingDomain.Authority))
                            {
                                //domain found so get the first item assigned to this domain
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("In FindEntityByUrl: Resolving entity by Domain URL {0}", () => fullUrlIncludingDomain.Authority);
                                var hostnameEntry = DomainList[fullUrlIncludingDomain.Authority];
                                //lastRevisionFound = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(hostnameEntry.ContentId, revisionStatusType);
                                lastItemFound = uow.Repositories.OfRevisionType(revisionStatusType).InIds(hostnameEntry.ContentId.AsEnumerableOfOne()).FirstOrDefault();
                                Mandate.That(lastItemFound != null, x => new InvalidOperationException("Could not find an entity with a revision status of '" + revisionStatusType.Alias + "', having a hostname '" + fullUrlIncludingDomain.Authority + "' and id: " + hostnameEntry.ContentId));
                            }
                            else
                            {
                                //no domain found for the current request, so we need to find the first routable node that doesn't require a domain
                                LogHelper.TraceIfEnabled <DefaultRoutingEngine>("In FindEntityByUrl: Resolving entity by Non-Domain URL");
                                //var root = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(FixedHiveIds.ContentVirtualRoot, revisionStatusType);
                                //Mandate.That(root != null, x => new InvalidOperationException("Could not find the content root"));
                                var domainListIds = DomainList.Select(d => d.ContentId).ToArray();

                                var firstLevelRelations =
                                    uow.Repositories.GetChildRelations(FixedHiveIds.ContentVirtualRoot, FixedRelationTypes.DefaultRelationType).OrderBy(
                                        x => x.Ordinal).ToArray();

                                //try to find a first level node that doesn't exist in our domain list
                                var firstNonHostnameEntity = firstLevelRelations.FirstOrDefault(x => !domainListIds.Contains(x.DestinationId));

                                // Issue #U5-112
                                // If we have found no entities that are NOT assigned to a domain, given that we have already tried to find
                                // content matching the current request's domain, we cannot route any content, therefore return null

                                // Also return null if there is no content
                                if (firstNonHostnameEntity == null || !firstLevelRelations.Any())
                                {
                                    return null;
                                }

                                var idToUse = firstNonHostnameEntity.DestinationId;
                                using (DisposableTimer.TraceDuration <DefaultRoutingEngine>("FindEntityByUrl: Querying for " + idToUse, "FindEntityByUrl: Query"))
                                    lastItemFound = uow.Repositories.OfRevisionType(revisionStatusType).InIds(idToUse.AsEnumerableOfOne()).FirstOrDefault();

                                ////if there is no first level node anywhere, then there is no content. Show a friendly message
                                //if (firstNonHostnameEntity == null && !firstLevelRelations.Any())
                                //    return null;

                                ////if we have a first level node not assigned to a domain, use the first, otherwise if all nodes are assigned to domains, then just use the first
                                //var idToUse = firstNonHostnameEntity == null ? firstLevelRelations.First().DestinationId : firstNonHostnameEntity.DestinationId;
                                //lastItemFound = uow.Repositories.OfRevisionType(revisionStatusType).InIds(idToUse.AsEnumerableOfOne()).FirstOrDefault();
                            }


                            // Now we will have the path from the current application root like:
                            //      /this/is/a/path/to/a/document
                            // Now we need to walk down the tree
                            if (lastItemFound != null && !string.IsNullOrWhiteSpace(path) && path != "/")
                            {
                                using (DisposableTimer.TraceDuration <DefaultRoutingEngine>("FindEntityByUrl: Calling GetEntityByPath for " + lastItemFound.Id + " " + path, "FindEntityByUrl: GetEntityByPath"))
                                    lastItemFound = uow
                                                    .Repositories
                                                    .GetEntityByPath <TypedEntity>(lastItemFound.Id,
                                                                                   path,
                                                                                   revisionStatusType,
                                                                                   true);
                            }

                            if (lastItemFound == null)
                            {
                                return new HttpRuntimeCacheParameters <EntityRouteResult>(
                                    new EntityRouteResult(null, EntityRouteStatus.FailedNotFoundByName));
                            }

                            return new HttpRuntimeCacheParameters <EntityRouteResult>(
                                new EntityRouteResult(lastItemFound, EntityRouteStatus.SuccessWithoutHostname));
                        }
                    }

                    return null;
                }
            }));
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            this.BtnClose.Activated += (object sender, EventArgs e) => {
                this.Close();
                NSApplication.SharedApplication.StopModalWithCode(0);
            };


            // Attributes
            BtnAddAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtAttributeName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name cannot be empty", "Alert");
                    return;
                }
                else if (string.IsNullOrEmpty(TxtAttributeValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute value cannot be empty", "Alert");
                    return;
                }
                IdentityProviderDto.AttributesMap.Add(TxtAttributeName.StringValue, TxtAttributeValue.StringValue);
                ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);
                TxtAttributeName.StringValue  = (NSString)string.Empty;
                TxtAttributeValue.StringValue = (NSString)string.Empty;
            };

            BtnRemoveAttribute.Activated += (object sender, EventArgs e) => {
                if (AttributeMapTableView.SelectedRows.Count > 0)
                {
                    foreach (var index in AttributeMapTableView.SelectedRows)
                    {
                        var ds = (AttributeMapTableView.DataSource) as DictionaryDataSource;
                        if (ds != null)
                        {
                            var entry = ds.Entries[(int)index];
                            ds.Datasource.Remove(entry);
                            ds.Entries.RemoveAt((int)index);
                        }
                    }
                    ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);
                }
            };

            if (IdentityProviderDto.AttributesMap == null)
            {
                IdentityProviderDto.AttributesMap = new Dictionary <string, string> ();
            }

            if (IdentityProviderDto.Schema == null)
            {
                IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto> ();
            }

            ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);

            // User Schema
            BtnAddUserSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtUserAttributeValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("User schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)UsersAttributeList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("User schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdUser.ToString();
                var ds  = (UsersMapTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(UsersAttributeList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("User schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(UsersAttributeList.SelectedValue.ToString(), TxtUserAttributeValue.StringValue);

                ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtUserAttributeValue.StringValue = (NSString)string.Empty;
                UsersAttributeList.SelectItem((nint)(-1));
            };

            BtnRemoveUserSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (UsersMapTableView.SelectedRows.Count > 0)
                {
                    var ds    = (UsersMapTableView.DataSource) as DictionaryDataSource;
                    var index = UsersMapTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdUser.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc = ObjectId.ObjectIdUser.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc))
            {
                IdentityProviderDto.Schema.Add(desc, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc].AttributeMappings)
                {
                    UserAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema[desc].AttributeMappings = attribMap;
            }
            ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[desc].AttributeMappings);

            // Password Schema
            BtnAddPasswordSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtPasswordValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Password schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)PasswordAttributeList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Password schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdPasswordSettings.ToString();
                var ds  = (PasswordTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(PasswordAttributeList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Password schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(PasswordAttributeList.SelectedValue.ToString(), TxtPasswordValue.StringValue);

                ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtPasswordValue.StringValue = (NSString)string.Empty;
                PasswordAttributeList.SelectItem((nint)(-1));
            };

            BtnRemovePasswordSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (PasswordTableView.SelectedRows.Count > 0)
                {
                    var ds    = (PasswordTableView.DataSource) as DictionaryDataSource;
                    var index = PasswordTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdPasswordSettings.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc1 = ObjectId.ObjectIdPasswordSettings.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc1))
            {
                IdentityProviderDto.Schema.Add(desc1, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string> ()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc1].AttributeMappings)
                {
                    PasswordAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc1].AttributeMappings = attribMap;
            }
            ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[desc1].AttributeMappings);


            // Group Schema
            BtnAddGroupSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtGroupValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Group schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)GroupAttributes.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Group schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdGroup.ToString();
                var ds  = (GroupAttributesTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(GroupAttributes.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Group schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(GroupAttributes.SelectedValue.ToString(), TxtGroupValue.StringValue);

                ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtGroupValue.StringValue = (NSString)string.Empty;
                GroupAttributes.SelectItem((nint)(-1));
            };

            BtnRemoveGroupSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (GroupAttributesTableView.SelectedRows.Count > 0)
                {
                    var ds    = (GroupAttributesTableView.DataSource) as DictionaryDataSource;
                    var index = GroupAttributesTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdGroup.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc2 = ObjectId.ObjectIdGroup.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc2))
            {
                IdentityProviderDto.Schema.Add(desc2, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc2].AttributeMappings)
                {
                    GroupAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc2].AttributeMappings = attribMap;
            }
            ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[desc2].AttributeMappings);

            // Domain Schema
            BtnAddDomainSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtDomainValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)DomainList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdDomain.ToString();
                var ds  = (DomainAttributesTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(DomainList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(DomainList.SelectedValue.ToString(), TxtDomainValue.StringValue);
                ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtDomainValue.StringValue = (NSString)string.Empty;
                DomainList.SelectItem((nint)(-1));
            };

            BtnRemoveDomainSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (DomainAttributesTableView.SelectedRows.Count > 0)
                {
                    var ds    = (DomainAttributesTableView.DataSource) as DictionaryDataSource;
                    var index = DomainAttributesTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdDomain.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc3 = ObjectId.ObjectIdDomain.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc3))
            {
                IdentityProviderDto.Schema.Add(desc3, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc3].AttributeMappings)
                {
                    DomainAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc3].AttributeMappings = attribMap;
            }
            ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[desc3].AttributeMappings);

            this.BtnApply.Activated += (object sender, EventArgs e) => {
                if (IsValid())
                {
                    IdentityProviderDto.BaseDnForNestedGroupsEnabled = BtnBaseDnForNestedGroups.StringValue == "1";
                    IdentityProviderDto.DirectGroupsSearchEnabled    = BtnGroupSearch.StringValue == "1";
                    IdentityProviderDto.MatchingRuleInChainEnabled   = BtnMatchRuleInChain.StringValue == "1";

                    var user = ObjectId.ObjectIdUser.ToString();
                    var pass = ObjectId.ObjectIdPasswordSettings.ToString();
                    var grp  = ObjectId.ObjectIdGroup.ToString();
                    var dmn  = ObjectId.ObjectIdDomain.ToString();
                    IdentityProviderDto.Schema [user].ObjectClass = UserClassName.StringValue;
                    IdentityProviderDto.Schema[pass].ObjectClass  = TxtPasswordClassName.StringValue;
                    IdentityProviderDto.Schema[grp].ObjectClass   = TxtGroupClassName.StringValue;
                    IdentityProviderDto.Schema[dmn].ObjectClass   = TxtDomainClassName.StringValue;

                    var schema = new Dictionary <string, SchemaObjectMappingDto>();

                    if (IdentityProviderDto.Schema[user].AttributeMappings.Count > 0)
                    {
                        schema.Add(user, IdentityProviderDto.Schema[user]);
                    }
                    if (IdentityProviderDto.Schema[pass].AttributeMappings.Count > 0)
                    {
                        schema.Add(pass, IdentityProviderDto.Schema[pass]);
                    }
                    if (IdentityProviderDto.Schema[grp].AttributeMappings.Count > 0)
                    {
                        schema.Add(grp, IdentityProviderDto.Schema[grp]);
                    }
                    if (IdentityProviderDto.Schema[dmn].AttributeMappings.Count > 0)
                    {
                        schema.Add(dmn, IdentityProviderDto.Schema[dmn]);
                    }

                    IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto>(schema);

                    this.Close();
                    NSApplication.SharedApplication.StopModalWithCode(1);
                }
            };

            if (IdentityProviderDto.AttributesMap == null)
            {
                IdentityProviderDto.AttributesMap = new Dictionary <string, string>();
            }
            if (IdentityProviderDto.Schema == null)
            {
                IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto>();
            }
            DtoToView();
        }
Beispiel #13
0
        static void PopulateAllUniqueDomains(StringBuilder buf, Dictionary <string, Regex> allUniqueDomains, params string[][] allDomains)
        {
            // Setup variables
            int listIndex = 0, stringIndex = 0;

            // Clear the dictionary
            allUniqueDomains.Clear();

            if (allDomains != null)
            {
                // Go through all the domains
                for (; listIndex < allDomains.Length; ++listIndex)
                {
                    if (allDomains[listIndex] != null)
                    {
                        // Go through all strings in the list
                        for (stringIndex = 0; stringIndex < allDomains[listIndex].Length; ++stringIndex)
                        {
                            // Add the entry and its regular expression equivalent
                            if (string.IsNullOrEmpty(allDomains[listIndex][stringIndex]) == false)
                            {
                                allUniqueDomains.Add(allDomains[listIndex][stringIndex], DomainList.ConvertToRegex(allDomains[listIndex][stringIndex], buf));
                            }
                        }
                    }
                }
            }
        }
Beispiel #14
0
        public override void Populate(object obj)
        {
            dtDominio = (DataTable)obj;
            try
            {
                cmbDominios.Properties.DisplayMember = "DomainName";
                cmbDominios.Properties.ValueMember   = "DomainGUID";


                //if (cmbDominios._ShowActiveFlag && cmbDominios._ActiveFlagChecked)
                //    active = true;

                if (dtDominio != null)
                {
                    //AccountList _List = AccountController.AccountGet(null, active);
                    //System.Data.DataRowCollection _Rows = _DtAuthenticationType.Rows;


                    DomainList wDomainList = new DomainList();

                    foreach (DataRow dr in dtDominio.Rows)
                    {
                        Domain wDomain = new Domain();

                        //wDomain.DomainId = Convert.ToInt32( dr.Table.Rows[0]["DomainId"]);
                        wDomain.DomainName = dr.Table.Rows[0]["DomainName"].ToString();
                        wDomain.DomainGUID = dr.Table.Rows[0]["DomainGUID"].ToString();

                        wDomainList.Add(wDomain);
                    }


                    #region [Agregado de Item a lista de acuerdo a propiedad _WithTextSelection]

                    //if (_WithTextSelection == true)
                    //{
                    //    DataRow wAccountBE_Seleccione = new AccountBE();
                    //    wAccountBE_Seleccione.AccountId = -1;
                    //    wAccountBE_Seleccione.AccountName = "Seleccione";
                    //    _List.Insert(0, wAccountBE_Seleccione);
                    //}

                    #endregion
                    cmbDominios.Properties.DataSource = wDomainList;
                    cmbDominios.Refresh();
                    cmbDominios.EditValue = cmbDominios.Properties.GetDataSourceValue(cmbDominios.Properties.ValueMember, 0);
                    //cmbDominios.Properties.PopulateColumns();

                    foreach (DevExpress.XtraEditors.Controls.LookUpColumnInfo col in cmbDominios.Properties.Columns)
                    {
                        if (col.FieldName != "DomainName")
                        {
                            col.Visible = false;
                        }
                    }

                    bFirstLoad = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #15
0
 public bool LsbSingle()
 {
     try
     {
         DbClient.ClearTestCollections();
         var networkActivitities = new List <BsonDocument>();
         if (SelectedUsers.Count < 1 || SelectedMachines[0].Name == null)
         {
             return(false);
         }
         networkActivitities.Add(DocumentCreator.SimpleBindCreator(SelectedUsers.FirstOrDefault(),
                                                                   SelectedMachines[0], SelectedDomainControllers.FirstOrDefault(), DomainList.Single(_ => _.Id == SelectedUsers.FirstOrDefault()?.Domain).Name
                                                                   , DomainList.Single(_ => _.Id == SelectedMachines[0].Domain).Name, SourceGateway));
         DbClient.InsertBatch(networkActivitities);
         return(true);
     }
     catch (Exception singleException)
     {
         Logger.Error(singleException);
         return(false);
     }
 }
Beispiel #16
0
 public bool LsbDistinct()
 {
     try
     {
         var networkActivitities = new List <BsonDocument>();
         if (SelectedUsers.Count < 11 || SelectedMachines.Count < 1)
         {
             return(false);
         }
         DbClient.ClearTestCollections();
         SvcCtrl.StopService("ATACenter");
         DbClient.SetCenterProfileForReplay();
         Logger.Debug("Center profile set for replay");
         networkActivitities.AddRange(
             SelectedUsers.Select(
                 user =>
                 DocumentCreator.SimpleBindCreator(user, SelectedMachines[0],
                                                   SelectedDomainControllers.FirstOrDefault(), DomainList.Single(_ => _.Id == user.Domain).Name
                                                   , DomainList.Single(_ => _.Id == SelectedMachines[0].Domain).Name, SourceGateway)));
         DbClient.InsertBatch(networkActivitities);
         Logger.Debug("Done inserting Ldap activities");
         SvcCtrl.StartService("ATACenter");
         return(true);
     }
     catch (Exception distinctException)
     {
         Logger.Error(distinctException);
         return(false);
     }
 }
Beispiel #17
0
        static void TestDomainAsset(Object testAsset, StringBuilder builder, StringCryptographer decrypter, out string testResult, out MessageType testResultType)
        {
            // Setup variables
            AssetBundle bundle = null;

            testResult     = TestErrorInvalidFileMessage;
            testResultType = MessageType.Error;

            // Null check
            if (testAsset == null)
            {
                // Don't do anything if asset is null
                return;
            }

            try
            {
                // Load the bundle, and convert it to a domain list
                bundle = AssetBundle.LoadFromFile(AssetDatabase.GetAssetPath(testAsset));
                DomainList domainList = Utility.GetDomainList(bundle);

                // By default, indicate the bundle doesn't contain DomainList
                testResult     = TestErrorInvalidAssetMessage;
                testResultType = MessageType.Error;

                // Check if the bundle contains an AcceptedDomainList
                if (domainList != null)
                {
                    // By default, indicate the domain list is empty
                    testResult     = TestEmptyWarningMessage;
                    testResultType = MessageType.Warning;
                    if ((domainList != null) && (domainList.Count > 0))
                    {
                        // list out all the domains in the list
                        builder.Clear();
                        builder.Append(TestInfoMessage);
                        for (int index = 0; index < domainList.Count; ++index)
                        {
                            builder.AppendLine();
                            builder.Append("* \"");
                            if (decrypter != null)
                            {
                                builder.Append(decrypter.Decrypt(domainList[index]));
                            }
                            else
                            {
                                builder.Append(domainList[index]);
                            }
                            builder.Append("\"");
                        }
                        testResult     = builder.ToString();
                        testResultType = MessageType.Info;
                    }
                }
            }
            finally
            {
                if (bundle != null)
                {
                    // Clean-up
                    bundle.Unload(true);
                }
            }
        }
Beispiel #18
0
        void ReleaseDesignerOutlets()
        {
            if (UserClassName != null)
            {
                UserClassName.Dispose();
                UserClassName = null;
            }

            if (TxtPasswordClassName != null)
            {
                TxtPasswordClassName.Dispose();
                TxtPasswordClassName = null;
            }

            if (TxtDomainClassName != null)
            {
                TxtDomainClassName.Dispose();
                TxtDomainClassName = null;
            }

            if (TxtGroupClassName != null)
            {
                TxtGroupClassName.Dispose();
                TxtGroupClassName = null;
            }

            if (AttributeMapTableView != null)
            {
                AttributeMapTableView.Dispose();
                AttributeMapTableView = null;
            }

            if (BtnAddAttribute != null)
            {
                BtnAddAttribute.Dispose();
                BtnAddAttribute = null;
            }

            if (BtnAddDomainSchemaAttribute != null)
            {
                BtnAddDomainSchemaAttribute.Dispose();
                BtnAddDomainSchemaAttribute = null;
            }

            if (BtnAddGroupSchemaAttribute != null)
            {
                BtnAddGroupSchemaAttribute.Dispose();
                BtnAddGroupSchemaAttribute = null;
            }

            if (BtnAddPasswordSchemaAttribute != null)
            {
                BtnAddPasswordSchemaAttribute.Dispose();
                BtnAddPasswordSchemaAttribute = null;
            }

            if (BtnAddUserSchemaAttribute != null)
            {
                BtnAddUserSchemaAttribute.Dispose();
                BtnAddUserSchemaAttribute = null;
            }

            if (BtnApply != null)
            {
                BtnApply.Dispose();
                BtnApply = null;
            }

            if (BtnBaseDnForNestedGroups != null)
            {
                BtnBaseDnForNestedGroups.Dispose();
                BtnBaseDnForNestedGroups = null;
            }

            if (BtnClose != null)
            {
                BtnClose.Dispose();
                BtnClose = null;
            }

            if (BtnGroupSearch != null)
            {
                BtnGroupSearch.Dispose();
                BtnGroupSearch = null;
            }

            if (BtnMatchRuleInChain != null)
            {
                BtnMatchRuleInChain.Dispose();
                BtnMatchRuleInChain = null;
            }

            if (BtnRemoveAttribute != null)
            {
                BtnRemoveAttribute.Dispose();
                BtnRemoveAttribute = null;
            }

            if (BtnRemoveDomainSchemaAttribute != null)
            {
                BtnRemoveDomainSchemaAttribute.Dispose();
                BtnRemoveDomainSchemaAttribute = null;
            }

            if (BtnRemoveGroupSchemaAttribute != null)
            {
                BtnRemoveGroupSchemaAttribute.Dispose();
                BtnRemoveGroupSchemaAttribute = null;
            }

            if (BtnRemovePasswordSchemaAttribute != null)
            {
                BtnRemovePasswordSchemaAttribute.Dispose();
                BtnRemovePasswordSchemaAttribute = null;
            }

            if (BtnRemoveUserSchemaAttribute != null)
            {
                BtnRemoveUserSchemaAttribute.Dispose();
                BtnRemoveUserSchemaAttribute = null;
            }

            if (DomainAttributesTableView != null)
            {
                DomainAttributesTableView.Dispose();
                DomainAttributesTableView = null;
            }

            if (DomainList != null)
            {
                DomainList.Dispose();
                DomainList = null;
            }

            if (GroupAttributes != null)
            {
                GroupAttributes.Dispose();
                GroupAttributes = null;
            }

            if (GroupAttributesTableView != null)
            {
                GroupAttributesTableView.Dispose();
                GroupAttributesTableView = null;
            }

            if (PasswordAttributeList != null)
            {
                PasswordAttributeList.Dispose();
                PasswordAttributeList = null;
            }

            if (PasswordTableView != null)
            {
                PasswordTableView.Dispose();
                PasswordTableView = null;
            }

            if (TxtAttributeName != null)
            {
                TxtAttributeName.Dispose();
                TxtAttributeName = null;
            }

            if (TxtAttributeValue != null)
            {
                TxtAttributeValue.Dispose();
                TxtAttributeValue = null;
            }

            if (TxtDomainValue != null)
            {
                TxtDomainValue.Dispose();
                TxtDomainValue = null;
            }

            if (TxtGroupValue != null)
            {
                TxtGroupValue.Dispose();
                TxtGroupValue = null;
            }

            if (TxtPasswordValue != null)
            {
                TxtPasswordValue.Dispose();
                TxtPasswordValue = null;
            }

            if (TxtUserAttributeValue != null)
            {
                TxtUserAttributeValue.Dispose();
                TxtUserAttributeValue = null;
            }

            if (UsersAttributeList != null)
            {
                UsersAttributeList.Dispose();
                UsersAttributeList = null;
            }

            if (UsersMapTableView != null)
            {
                UsersMapTableView.Dispose();
                UsersMapTableView = null;
            }
        }
Beispiel #19
0
        /// <summary>
        /// Returns the non-domain URL for the 'self' node in ancestorsOrSelf or null if this node cannot
        /// exist in a non-domain branch.
        /// </summary>
        /// <param name="ancestorsOrSelf"></param>
        /// <returns></returns>
        protected UrlResolutionResult GetNonDomainUrl(IEnumerable <TypedEntity> ancestorsOrSelf)
        {
            using (var uow = ApplicationContext.Hive.OpenReader <IContentStore>())
            {
                var domainListIds = DomainList.Select(x => x.ContentId);

                var contentRootExists = uow.Repositories.Exists <TypedEntity>(FixedHiveIds.ContentVirtualRoot);
                Mandate.That(contentRootExists, x => new NullReferenceException("No ContentVirtualRoot exists!"));

                var firstLevelRelations = uow.Repositories
                                          .GetChildRelations(FixedHiveIds.ContentVirtualRoot, FixedRelationTypes.DefaultRelationType)
                                          .OrderBy(x => x.Ordinal)
                                          .ToArray();

                var firstLevelIds = firstLevelRelations.Select(x => x.DestinationId).ToArray();
                var ancestorIds   = ancestorsOrSelf.Select(x => x.Id).ToArray();

                //returns true if the branch passed in is part of the first branch found that doesn't have a domain assigned
                Func <IEnumerable <HiveId>, bool> isFirstBranchNotAssignedADomain = branchIds =>
                {
                    var firstLevelIdsWithoutDomains = firstLevelIds.Where(x => !domainListIds.Contains(x));
                    var firstBranchWithoutDomain    = firstLevelIdsWithoutDomains.First();
                    return(branchIds.Contains(firstBranchWithoutDomain));
                };

                //if there's only one node,
                // OR the current branch isnt't assigned to a domain and its part of the first branch that isn't assigned to a domain,
                // OR all first level nodes are assigned to domains and the requesting node is part of the very first branch

                if (firstLevelRelations.Count() == 1 ||
                    (!domainListIds.ContainsAny(ancestorIds) && isFirstBranchNotAssignedADomain(ancestorIds)) ||
                    (domainListIds.ContainsAll(firstLevelIds) && ancestorIds.Contains(firstLevelIds.First())))
                {
                    //if there's only one node, just pick it, otherwise get the first without hostnames
                    var firstLevelRelationWithoutHostname = firstLevelRelations.Count() == 1
                        ? firstLevelRelations.First()
                        : firstLevelRelations.FirstOrDefault(x => !domainListIds.Contains(x.DestinationId));

                    if (firstLevelRelationWithoutHostname == null)
                    {
                        // This can happen if multiple roots exist, each with a hostname assigned
                        // Therefore the current entity does not have a non-domain url, but that's
                        // still a valid scenario, just not one that GetNonDomainUrl can handle
                        return(new UrlResolutionResult(string.Empty, UrlResolutionStatus.OnlyDomainUrlsValid));

                        ////NOTE: I don't think this ever will happen! The initial thought wa that the relations api will ony return the latest published versions but this is not true, they return the latest version

                        ////can't find a first routable branch, so must not be published
                        //return new UrlResolutionResult(string.Empty, UrlResolutionStatus.FailedNotPublished);
                    }

                    //ok, now we can give it a URL

                    var appPath    = _httpContext.Request.ApplicationPath.TrimEnd('/');
                    var level      = 0;
                    var urlBuilder = new StringBuilder();
                    urlBuilder.Append(appPath);

                    foreach (var e in ancestorsOrSelf)
                    {
                        if (level > 0)
                        {
                            var urlAlias = e.InnerAttribute <string>(NodeNameAttributeDefinition.AliasValue, "UrlName");
                            if (!string.IsNullOrEmpty(urlAlias))
                            {
                                urlBuilder.Append("/");
                                urlBuilder.Append(urlAlias);
                            }
                        }
                        level++;
                    }

                    var url = "/" + urlBuilder.ToString().Trim('/');

                    return(new UrlResolutionResult(url, UrlResolutionStatus.SuccessWithoutHostname));
                }

                return(null);
            }
        }
Beispiel #20
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MimeKit.MailboxAddress"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="MailboxAddress"/> with the specified name and address. The
		/// specified text encoding is used when encoding the name according to the rules of rfc2047.
		/// </remarks>
		/// <param name="encoding">The character encoding to be used for encoding the name.</param>
		/// <param name="name">The name of the mailbox.</param>
		/// <param name="address">The address of the mailbox.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <para><paramref name="encoding"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="address"/> is <c>null</c>.</para>
		/// </exception>
		public MailboxAddress (Encoding encoding, string name, string address) : base (encoding, name)
		{
			Route = new DomainList ();
			Route.Changed += RouteChanged;

			this.address = address;
		}
Beispiel #21
0
        static bool TryParse(string text, ref int index, out InternetAddress addr)
        {
            string     name, route, user, domain;
            DomainList domains;

            addr = null;

            if (text[index] != '(')
            {
                return(false);
            }

            index++;

            if (!TryParse(text, ref index, out name))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out route))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out user))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out domain))
            {
                return(false);
            }

            while (index < text.Length && text[index] == ' ')
            {
                index++;
            }

            if (index >= text.Length || text[index] != ')')
            {
                return(false);
            }

            index++;

            if (domain != null)
            {
                var address = user + "@" + domain;

                if (route != null && DomainList.TryParse(route, out domains))
                {
                    addr = new MailboxAddress(name, domains, address);
                }
                else
                {
                    addr = new MailboxAddress(name, address);
                }
            }
            else if (user != null)
            {
                addr = new GroupAddress(user);
            }

            return(true);
        }
Beispiel #22
0
 private void SortASCButton_Click(object sender, EventArgs e)
 {
     DomainList = new BindingList <Domain>(DomainList.OrderBy(x => x.Name).ToList());
     DomainListbox.DataSource = DomainList;
     UnsavedModifications     = true;
 }
Beispiel #23
0
        public MemoryApi()
        {
            constructedCommands.Add(new ApiCommand("ReadByte", WrapMemoryCall((a, d) => (int)ReadUnsignedByte(a, d)), DocParams.ReadParams, "Reads the byte at Address"));
            constructedCommands.Add(new ApiCommand("WriteByte", WrapMemoryCall((a, v, d) => WriteUnsignedByte(a, (uint)v, d)), DocParams.WriteParams, "Writes the byte Value at Address"));

            void ByteSizeCommands(int bytes)
            {
                constructedCommands.Add(new ApiCommand($"ReadS{bytes * 8}BE", WrapMemoryCall((a, d) => ReadSignedBig(a, bytes, d), bytes), DocParams.ReadParams, $"Reads the signed {bytes * 8}-bit big-endian value at Address"));
                constructedCommands.Add(new ApiCommand($"ReadS{bytes * 8}LE", WrapMemoryCall((a, d) => ReadSignedLittle(a, bytes, d), bytes), DocParams.ReadParams, $"Reads the signed {bytes * 8}-bit little-endian value at Address"));
                constructedCommands.Add(new ApiCommand($"ReadU{bytes * 8}BE", WrapMemoryCall((a, d) => (int)ReadUnsignedBig(a, bytes, d), bytes), DocParams.ReadParams, $"Reads the unsigned {bytes * 8}-bit big-endian value at Address"));
                constructedCommands.Add(new ApiCommand($"ReadU{bytes * 8}LE", WrapMemoryCall((a, d) => (int)ReadUnsignedLittle(a, bytes, d), bytes), DocParams.ReadParams, $"Reads the unsigned {bytes * 8}-bit little-endian value at Address"));
                constructedCommands.Add(new ApiCommand($"WriteS{bytes * 8}BE", WrapMemoryCall((a, v, d) => WriteSignedBig(a, v, bytes, d)), DocParams.WriteParams, $"Writes Value as a signed {bytes * 8}-bit big-endian integer at Address"));
                constructedCommands.Add(new ApiCommand($"WriteS{bytes * 8}LE", WrapMemoryCall((a, v, d) => WriteSignedLittle(a, v, bytes, d)), DocParams.WriteParams, $"Writes Value as a signed, {bytes * 8}-bit little-endian integer at Address"));
                constructedCommands.Add(new ApiCommand($"WriteU{bytes * 8}BE", WrapMemoryCall((a, v, d) => WriteUnsignedBig(a, (uint)v, bytes, d)), DocParams.WriteParams, $"Writes Value as an unsigned, {bytes * 8}-bit big-endian integer at Address"));
                constructedCommands.Add(new ApiCommand($"WriteU{bytes * 8}LE", WrapMemoryCall((a, v, d) => WriteUnsignedLittle(a, (uint)v, bytes, d)), DocParams.WriteParams, $"Writes Value as an unsigned {bytes * 8}-bit little-endian integer at Address"));
            }

            for (var b = 2; b <= 4; ByteSizeCommands(b++))
            {
                ;                                                        //16, 24, and 32-bit commands
            }
            constructedCommands.Add(new ApiCommand("ReadByteRange", WrapMultiMemoryCall(ReadRegion), DocParams.ReadRange, "Reads Length bytes of memory starting at Address"));
            constructedCommands.Add(new ApiCommand("WriteByteRange", WrapMemoryCall(WriteRegion), DocParams.WriteRange, "Writes Data to memory starting at Address"));

            constructedCommands.Add(new ApiCommand("CheckFlag", WrapMemoryCall((a, f, d) => CheckFlag(a, f, d)), DocParams.FlagsParams, "Checks the value of Flag in flags starting at Address"));
            constructedCommands.Add(new ApiCommand("SetFlag", WrapMemoryCall((a, f, d) => SetFlag(a, f, d)), DocParams.FlagsParams, "Sets the Flag in flags starting at Address"));
            constructedCommands.Add(new ApiCommand("ClearFlag", WrapMemoryCall((a, f, d) => ClearFlag(a, f, d)), DocParams.FlagsParams, "Clears the Flag in flags starting at Address"));

            constructedCommands.Add(new ApiCommand("HashByteRange", WrapMemoryCall(HashRegion), DocParams.ReadRange, "Calculates the SHA256 hash of Length bytes of memory starting at Address"));

            constructedCommands.Add(new ApiCommand("Disassemble", WrapMemoryCall((a, d) => Disassemble((uint)a, d)), DocParams.ReadParams, "Generates a disassembly of the instruction at Address"));

            constructedCommands.Add(new ApiCommand("MemoryDomains", (a, d) => string.Join("\n", DomainList?.Select(m => m.Name)), new List <ApiParameter>(), "Lists available memory domains for the current core."));
            constructedCommands.Add(new ApiCommand("SetDefaultMemoryDomain", (a, d) => _UseMemoryDomain(a.FirstOrDefault() ?? d), new List <ApiParameter>()
            {
                new ApiParameter("Domain", "string")
            }, "Sets which memory domain gets used when no domain is provided"));

            constructedCommands.Add(new ApiCommand("OnMemoryRead", WrapMemoryEvent(MemoryCallbackType.Read, SetMemoryEvent), DocParams.EventParams, "Blocks emulation and connects to the provided CallbackUrl when Address (Length bytes) is read from. System Bus only. Returns the Name of the callback in case you wish to remove it later."));
            constructedCommands.Add(new ApiCommand("OnMemoryWrite", WrapMemoryEvent(MemoryCallbackType.Write, SetMemoryEvent), DocParams.EventParams, "Blocks emulation and connects to the provided CallbackUrl when Address (Length bytes) is written to. System Bus only. Returns the Name of the callback in case you wish to remove it later."));
            constructedCommands.Add(new ApiCommand("OnMemoryExecute", WrapMemoryEvent(MemoryCallbackType.Execute, SetMemoryEvent), DocParams.EventParams, "Blocks emulation and connects to the provided CallbackUrl when Address (Length bytes) is executed. System Bus only. Returns the Name of the callback in case you wish to remove it later."));

            constructedCommands.Add(new ApiCommand("OnMemoryReadIfValue", WrapConditionalMemoryEvent(MemoryCallbackType.Read, SetMemoryEvent), DocParams.ConditionalEventParams, "Blocks emulation and connects to the provided CallbackUrl when Address1 (Length bytes) is read from, as long as Address2 is Value. System Bus only. Returns the Name of the callback in case you wish to remove it later."));
            constructedCommands.Add(new ApiCommand("OnMemoryWriteIfValue", WrapConditionalMemoryEvent(MemoryCallbackType.Write, SetMemoryEvent), DocParams.ConditionalEventParams, "Blocks emulation and connects to the provided CallbackUrl when Address1 (Length bytes) is written to, as long as Address2 is Value. System Bus only. Returns the Name of the callback in case you wish to remove it later."));
            constructedCommands.Add(new ApiCommand("OnMemoryExecuteIfValue", WrapConditionalMemoryEvent(MemoryCallbackType.Execute, SetMemoryEvent), DocParams.ConditionalEventParams, "Blocks emulation and connects to the provided CallbackUrl when Address1 (Length bytes) is executed, as long as Address2 is Value. System Bus only. Returns the Name of the callback in case you wish to remove it later."));

            constructedCommands.Add(new ApiCommand("RemoveMemoryCallback", WrapVoidDomain(RemoveMemoryEvent), new List <ApiParameter> {
                DocParams.EventName
            }, "Removes the memory callback, looking it up by its given Name."));
        }
Beispiel #24
0
		public void TestParseEmptyDomains ()
		{
			var expected = new DomainList (new [] { "domain1", "domain2" });

			AssertParse ("@domain1,,@domain2", expected);
		}
Beispiel #25
0
        private static void SetDns()
        {
            ILog _log = LogManager.GetLogger(typeof(Program));

            LogManager.Configure("logs\\log.txt", 1024, false);
            int success = 0;

            try
            {
                Config       cfg    = Config.Load("config.json");
                DnspodClient client = new DnspodClient(cfg.email, cfg.password);
                DomainList   list   = client.GetDomains();
                Dictionary <string, SimpleDDNS.Clients.Dnspod.Domain> domainDict = list.GetDomainDict();
                if (cfg.domains != null)
                {
                    for (int i = 0; i < cfg.domains.Count; i++)
                    {
                        if (cfg.domains[i].records != null && cfg.domains[i].records.Count > 0 &&
                            domainDict.ContainsKey(cfg.domains[i].name))
                        {
                            SimpleDDNS.Clients.Dnspod.Domain d = domainDict[cfg.domains[i].name];
                            RecordList rlist = client.GetRecords(d.id);
                            if (rlist != null && rlist.records != null)
                            {
                                Dictionary <string, SimpleDDNS.Clients.Dnspod.Record> records = rlist.GetRecordDict();

                                for (int j = 0; j < cfg.domains[i].records.Count; j++)
                                {
                                    Record r = cfg.domains[i].records[j];
                                    if (records.ContainsKey(r.name))
                                    {
                                        string value = GetIP(r.index);
                                        if (r.ip == IPType.internet)
                                        {
                                            value = GetIP(-1);
                                        }
                                        try
                                        {
                                            RecordUpdate ru = client.UpdateRecord(d.id, records[r.name].id, r.name, value);
                                            if (ru != null && ru.status != null && ru.status.code == "1")
                                            {
                                                string msg = string.Format("成功解析{0}.{1} -> {2}", r.name, d.name, value);
                                                Console.WriteLine(msg);
                                                _log.Info(msg);
                                                success++;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            _log.Error(ex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
            }
            Console.WriteLine("成功解析{0}个域名! 3秒钟后退出...", success);
            Thread.Sleep(3000);
        }
Beispiel #26
0
        public bool ExecuteLearningTime()
        {
            try
            {
                var sourceMachine = Machines.Single(_ => _.Name == "APP1");
                var sourceUser    = Users.Single(_ => _.Name == "triservice");
                // Generate Samr for domainController learning time
                foreach (var domainController in DomainControllers)
                {
                    ActivitiesList.Add(DocumentCreator.SamrCreator(sourceUser, sourceMachine,
                                                                   domainController,
                                                                   DomainList.Single(_ => _.Id == sourceUser.Domain).Name
                                                                   , DomainList.Single(_ => _.Id == sourceMachine.Domain).Name, SourceGateway, true,
                                                                   SamrQueryType.EnumerateUsers, SamrQueryOperation.EnumerateUsersInDomain,
                                                                   DomainList.Single(_ => _.Id == sourceMachine.Domain).Id, 35));
                }

                InsertActivities(true);

                do
                {
                    SamrReconnaissanceDetectorProfile = GetSamrDetectorProfile();
                } while (SamrReconnaissanceDetectorProfile["DestinationComputerIdToDetectionStartTimeMapping"]
                         .AsBsonArray.Count != DomainControllers.Count);

                foreach (var coupledSamr in SamrCouples)
                {
                    var samrAmount = coupledSamr.RatingType == "Low" ? 10 : 21;
                    for (var samrIndex = 0; samrIndex < samrAmount; samrIndex++)
                    {
                        var queriedObject = Users[_random.Next(Users.Count)];
                        ActivitiesList.Add(DocumentCreator.SamrCreator(coupledSamr.User, coupledSamr.Machine,
                                                                       DomainControllers.First(_ => _.Domain == DomainList.Single(__ => __.Id == coupledSamr.Machine.Domain).Id),
                                                                       DomainList.Single(_ => _.Id == coupledSamr.User.Domain).Name
                                                                       , DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Name, SourceGateway, true,
                                                                       SamrQueryType.QueryUser, SamrQueryOperation.QueryInformationUser,
                                                                       DomainList.Single(_ => _.Id == coupledSamr.Machine.Domain).Id, 10, queriedObject));
                    }
                }

                InsertActivities();

                do
                {
                    SamrReconnaissanceDetectorProfile = GetSamrDetectorProfile();
                } while (SamrReconnaissanceDetectorProfile["DateToQueryToSamrQueryDataMapping"]
                         .AsBsonArray.Count == 0);

                return(true);
            }
            catch (Exception e)
            {
                Logger.Debug(e);
                return(false);
            }
        }