Inheritance: GUI.Scope
Example #1
0
        //
        // Load/Store implementation
        //

        //
        // Loading with query results
        //

        internal override void LoadValueIntoProperty(string propertyName, object value)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "Group", "LoadValueIntoProperty: name=" + propertyName + " value=" + (value != null ? value.ToString() : "null"));

            switch (propertyName)
            {
            case PropertyNames.GroupIsSecurityGroup:
                _isSecurityGroup        = (bool)value;
                _isSecurityGroupChanged = LoadState.Loaded;
                break;

            case PropertyNames.GroupGroupScope:
                _groupScope        = (GroupScope)value;
                _groupScopeChanged = LoadState.Loaded;
                break;

            case PropertyNames.GroupMembers:
                Debug.Fail("Group.LoadValueIntoProperty: Trying to load Members, but Members is demand-loaded.");
                break;

            default:
                base.LoadValueIntoProperty(propertyName, value);
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Serializes the <see cref="LogColumn"/> instance to XML.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> instance to serialize into.</param>
        /// <returns><c>True</c> if the serialialzation was successfull; otherwise <c>false</c>.</returns>
        public bool SerializeToXml(XmlWriter writer)
        {
            if (writer != null)
            {
                writer.WriteStartElement("LogColumn");

                writer.WriteAttributeString(
                    "Name"
                    , Name);

                writer.WriteAttributeString(
                    "Expression"
                    , Expression);

                writer.WriteAttributeString(
                    "GroupScope"
                    , GroupScope.ToString());

                writer.WriteAttributeString(
                    "Optional"
                    , Optional.ToString());

                writer.WriteAttributeString(
                    "Type"
                    , ((int)(ColumnType)).ToString());

                writer.WriteEndElement();

                return(true);
            }

            return(false);
        }
Example #3
0
        internal override void LoadValueIntoProperty(string propertyName, object value)
        {
            string str  = propertyName;
            string str1 = str;

            if (str != null)
            {
                if (str1 == "GroupPrincipal.IsSecurityGroup")
                {
                    this.isSecurityGroup        = (bool)value;
                    this.isSecurityGroupChanged = LoadState.Loaded;
                    return;
                }
                else
                {
                    if (str1 == "GroupPrincipal.GroupScope")
                    {
                        this.groupScope        = (GroupScope)value;
                        this.groupScopeChanged = LoadState.Loaded;
                        return;
                    }
                    else
                    {
                        if (str1 == "GroupPrincipal.Members")
                        {
                            return;
                        }
                    }
                }
            }
            base.LoadValueIntoProperty(propertyName, value);
        }
Example #4
0
        public static void ConfigureService
            (this IServiceCollection services, IConfiguration configuration)
        {
            services.AddDbContext <InitialDatabase>(options =>
                                                    options.UseSqlServer(configuration.GetConnectionString("InitialDatabase"))
                                                    );

            // A chamada a este Filter aqui, permite que ele também utilize o AccountScope

            services.AddScoped <AccountTicketBinderFilter>();

            // Inicializadores dos serviços e repositórios da aplicação

#warning Separar em módulos

            EnterpriseScope.Bind(services);

            AccountScope.Bind(services);

            GroupScope.Bind(services);

            AreaScope.Bind(services);

            CustomerScope.Bind(services);
        }
Example #5
0
        public void GroupScopeShouldBeStored(GroupScope groupScope)
        {
            // Fixture setup
            var group = Fixture.Create <Group>();

            // Exercise system
            group.Scope = groupScope;

            // Verify outcome
            group.Scope.Should().Be(groupScope);
        }
        /// <summary>
        /// Creates a new group in Active Directory
        /// </summary>
        /// <param name="sOU">The OU location you want to save your new Group</param>
        /// <param name="sGroupName">The name of the new group</param>
        /// <param name="sDescription">The description of the new group</param>
        /// <param name="oGroupScope">The scope of the new group</param>
        /// <param name="bSecurityGroup">True is you want this group to be a security group, false if you want this as a distribution group</param>
        /// <returns>Retruns the GroupPrincipal object</returns>
        public GroupPrincipal CreateNewGroup(string sOU, string sGroupName, string sDescription, GroupScope oGroupScope, bool bSecurityGroup)
        {
            PrincipalContext oPrincipalContext = GetPrincipalContext(sOU);

            GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName);
            oGroupPrincipal.Description = sDescription;
            oGroupPrincipal.GroupScope = oGroupScope;
            oGroupPrincipal.IsSecurityGroup = bSecurityGroup;
            oGroupPrincipal.Save();

            return oGroupPrincipal;
        }
Example #7
0
 /// <summary>
 /// Konstruktor für Gruppen
 /// </summary>
 /// <param name="sID"></param>
 /// <param name="name"></param>
 /// <param name="samAccountName"></param>
 /// <param name="distinguishedName"></param>
 /// <param name="description"></param>
 /// <param name="isSecurityGroup"></param>
 /// <param name="groupScope"></param>
 public ADElement(string sid, string name, string samAccountName, string distinguishedName, string description,
                  bool isSecurityGroup, GroupScope groupScope)
 {
     SID               = sid;
     Name              = name;
     SamAccountName    = samAccountName;
     DistinguishedName = distinguishedName;
     Description       = description;
     IsSecurityGroup   = isSecurityGroup;
     GroupScope        = groupScope;
     Type              = ADElementType.Group;
 }
Example #8
0
        private static bool GroupTypeMatcher(FilterBase filter, string winNTPropertyName, DirectoryEntry de)
        {
            GroupScope value = (GroupScope)filter.Value;

            if (value != GroupScope.Local)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #9
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ GroupScope.GetHashCode();
                hashCode = (hashCode * 397) ^ IsSecurityGroup.GetHashCode();

                return(hashCode);
            }
        }
        /// <summary>
        /// Creates a new group in Active Directory
        /// </summary>
        /// <param name="sOu">The OU location you want to save your new Group</param>
        /// <param name="sGroupName">The name of the new group</param>
        /// <param name="sDescription">The description of the new group</param>
        /// <param name="oGroupScope">The scope of the new group</param>
        /// <param name="bSecurityGroup">True is you want this group
        /// to be a security group, false if you want this as a distribution group</param>
        /// <returns>Returns the GroupPrincipal object</returns>
        public GroupPrincipal CreateNewGroup(string sOu, string sGroupName,
                                             string sDescription, GroupScope oGroupScope, bool bSecurityGroup)
        {
            PrincipalContext oPrincipalContext = GetPrincipalContext(sOu);

            GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName);

            oGroupPrincipal.Description     = sDescription;
            oGroupPrincipal.GroupScope      = oGroupScope;
            oGroupPrincipal.IsSecurityGroup = bSecurityGroup;
            oGroupPrincipal.Save();

            return(oGroupPrincipal);
        }
Example #11
0
        protected static string GroupTypeConverter(FilterBase filter, string suggestedAdProperty)
        {
            Debug.Assert(string.Equals(suggestedAdProperty, "groupType", StringComparison.OrdinalIgnoreCase));
            Debug.Assert(filter is GroupIsSecurityGroupFilter || filter is GroupScopeFilter);

            // 1.2.840.113556.1.4.803 is like a bit-wise AND operator
            switch (filter.PropertyName)
            {
            case GroupIsSecurityGroupFilter.PropertyNameStatic:

                bool value = (bool)filter.Value;

                // GROUP_TYPE_SECURITY_ENABLED
                // If group is enabled, it IS security-enabled
                if (value)
                {
                    return("(groupType:1.2.840.113556.1.4.803:=2147483648)");
                }
                else
                {
                    return("(!(groupType:1.2.840.113556.1.4.803:=2147483648))");
                }

            case GroupScopeFilter.PropertyNameStatic:

                GroupScope value2 = (GroupScope)filter.Value;

                switch (value2)
                {
                case GroupScope.Local:
                    // GROUP_TYPE_RESOURCE_GROUP, a.k.a. ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP
                    return("(groupType:1.2.840.113556.1.4.803:=4)");

                case GroupScope.Global:
                    // GROUP_TYPE_ACCOUNT_GROUP, a.k.a. ADS_GROUP_TYPE_GLOBAL_GROUP
                    return("(groupType:1.2.840.113556.1.4.803:=2)");

                default:
                    // GROUP_TYPE_UNIVERSAL_GROUP, a.k.a. ADS_GROUP_TYPE_UNIVERSAL_GROUP
                    Debug.Assert(value2 == GroupScope.Universal);
                    return("(groupType:1.2.840.113556.1.4.803:=8)");
                }

            default:
                Debug.Fail("ADStoreCtx.GroupTypeConverter: fell off end looking for " + filter.PropertyName);
                return("");
            }
        }
Example #12
0
        private static bool GroupTypeMatcher(FilterBase filter, string winNTPropertyName, DirectoryEntry de)
        {
            Debug.Assert(winNTPropertyName == "groupType");
            Debug.Assert(filter is GroupScopeFilter);

            GroupScope valueToMatch = (GroupScope)filter.Value;

            // All SAM local machine groups are local groups
            if (valueToMatch == GroupScope.Local)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
        IStoryThread EnchantExecute(IEnumerable <HarloweEnchantment> enchantments, Func <IStoryThread> fragment)
        {
            foreach (HarloweEnchantment enchantment in enchantments)
            {
                bool isHookRef = enchantment.ReferenceType == HarloweEnchantReferenceType.Hook;
                int  index     = isHookRef && enchantment.Command != HarloweEnchantCommand.Append ?
                                 enchantment.HookGroup.Index + 1 :
                                 -1;

                if (enchantment.Affected.Count > 0)
                {
                    if (index == -1)
                    {
                        index =
                            enchantment.Command == HarloweEnchantCommand.Append ? enchantment.Affected.Last().Index + 1 :
                            enchantment.Affected[0].Index;
                    }

                    // Remove affected outputs to be replaced
                    if (enchantment.Command == HarloweEnchantCommand.Replace)
                    {
                        for (int i = 0; i < enchantment.Affected.Count; i++)
                        {
                            OutputRemove(enchantment.Affected[i]);
                        }
                    }
                }

                this.InsertStack.Push(index);
                _activeEnchantments.Push(enchantment);

                GroupScope scope = isHookRef ? scope = Group(enchantment.HookGroup) : null;
                using (scope)
                {
                    // Execute the enchantment thread
                    yield return(this.fragment(fragment));
                }

                _activeEnchantments.Pop();

                // Reset the index
                this.InsertStack.Pop();
            }
        }
Example #14
0
        public static bool ChangeGroupScope(string s, GroupScope gp, AdAdminConfig config)
        {
            try
            {
                PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
                                                            config.ServerIpOrDomain,
                                                            config.AdminAccount,
                                                            config.AdminPwd);
                GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, s);
                if (group != null)
                {
                    group.GroupScope = gp;
                    group.Save();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                return(false);
            }
        }
        /// <summary>
        /// Creates a new group in Active Directory
        /// </summary>
        /// <param name="sOU">The OU location you want to save your new Group</param>
        /// <param name="sGroupName">The name of the new group</param>
        /// <param name="sDescription">The description of the new group</param>
        /// <param name="oGroupScope">The scope of the new group</param>
        /// <param name="bSecurityGroup">True is you want this group to be a security group, false if you want this as a distribution group</param>
        /// <returns>Retruns the GroupPrincipal object</returns>
        public GroupPrincipal CreateNewGroup(string sOU, string sGroupName, string sDescription, GroupScope oGroupScope, bool bSecurityGroup)
        {
            var oPrincipalContext = GetPrincipalContext(sOU);

            var oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName)
            {
                Description     = sDescription,
                GroupScope      = oGroupScope,
                IsSecurityGroup = bSecurityGroup
            };

            oGroupPrincipal.Save();

            return(oGroupPrincipal);
        }
Example #16
0
		internal override void LoadValueIntoProperty(string propertyName, object value)
		{
			string str = propertyName;
			string str1 = str;
			if (str != null)
			{
				if (str1 == "GroupPrincipal.IsSecurityGroup")
				{
					this.isSecurityGroup = (bool)value;
					this.isSecurityGroupChanged = LoadState.Loaded;
					return;
				}
				else
				{
					if (str1 == "GroupPrincipal.GroupScope")
					{
						this.groupScope = (GroupScope)value;
						this.groupScopeChanged = LoadState.Loaded;
						return;
					}
					else
					{
						if (str1 == "GroupPrincipal.Members")
						{
							return;
						}
					}
				}
			}
			base.LoadValueIntoProperty(propertyName, value);
		}
Example #17
0
        //
        // Load/Store implementation
        //

        //
        // Loading with query results
        //

        internal override void LoadValueIntoProperty(string propertyName, object value)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "Group", "LoadValueIntoProperty: name=" + propertyName + " value=" + (value != null ? value.ToString() : "null"));

            switch (propertyName)
            {
                case PropertyNames.GroupIsSecurityGroup:
                    _isSecurityGroup = (bool)value;
                    _isSecurityGroupChanged = LoadState.Loaded;
                    break;

                case PropertyNames.GroupGroupScope:
                    _groupScope = (GroupScope)value;
                    _groupScopeChanged = LoadState.Loaded;
                    break;

                case PropertyNames.GroupMembers:
                    Debug.Fail("Group.LoadValueIntoProperty: Trying to load Members, but Members is demand-loaded.");
                    break;

                default:
                    base.LoadValueIntoProperty(propertyName, value);
                    break;
            }
        }
Example #18
0
        /// <summary>
        /// Creates a new group in the specified location where the name, displayName, and
        /// SamAccountName are the value of the name parameter.
        /// </summary>
        /// <param name="name">The new group's name, display name and SamAccountName.</param>
        /// <param name="location">The OU's distinguishedName where the new group should created.</param>
        /// <param name="description">The description of the new group.</param>
        /// <param name="scope">The GroupScope of the new group.</param>
        /// <param name="isSecurityGroup">A boolean designating the new group as a security group or not.</param>
        /// <returns>The GroupPrincipal object of the new group..</returns>
        public static GroupPrincipal CreateGroup(string name, string location, string description, GroupScope scope, bool isSecurityGroup)
        {
            GroupPrincipal newGroup = new GroupPrincipal(GetPrincipalContext(location), name);

            newGroup.GroupScope      = scope;
            newGroup.IsSecurityGroup = isSecurityGroup;
            newGroup.Name            = name;
            newGroup.DisplayName     = name;
            newGroup.Description     = description;
            newGroup.Save();
            return(newGroup);
        }
 public void ConvertGroup(string groupName, GroupScope groupScope, GroupType groupType)
 {
 }
        public void CreateGroup(string groupName, GroupType groupType, GroupScope groupScope, string description = null, string organisationUnit = null, IEnumerable <UserAccount> members = null)
        {
            System.DirectoryServices.AccountManagement.GroupScope scope;

            switch (groupScope)
            {
            case GroupScope.Local:
                scope = System.DirectoryServices.AccountManagement.GroupScope.Local;
                break;

            case GroupScope.Global:
                scope = System.DirectoryServices.AccountManagement.GroupScope.Global;
                break;

            case GroupScope.Universal:
                scope = System.DirectoryServices.AccountManagement.GroupScope.Universal;
                break;

            default:
                scope = System.DirectoryServices.AccountManagement.GroupScope.Universal;
                break;
            }

            bool isSecurityGroup;

            switch (groupType)
            {
            case GroupType.Distribution:
                isSecurityGroup = false;
                break;

            case GroupType.Security:
                isSecurityGroup = true;
                break;

            default:
                isSecurityGroup = false;
                break;
            }

            // NEED TO CHECK IF OU IS A DISTINGUISED NAME THAT EXISTS
            var context = organisationUnit != null ? new PrincipalContext(ContextType.Domain, null, organisationUnit) : new PrincipalContext(ContextType.Domain);

            using (context)
                using (var groupPrincipal = new GroupPrincipal(context))
                {
                    groupPrincipal.Name            = groupName;
                    groupPrincipal.SamAccountName  = groupName;
                    groupPrincipal.Description     = description;
                    groupPrincipal.IsSecurityGroup = isSecurityGroup;
                    groupPrincipal.GroupScope      = scope;
                    groupPrincipal.Save();
                }

            if (members == null)
            {
                return;
            }
            foreach (var user in members)
            {
                AddUsertoGroup(user.Username, groupName);
            }
        }
Example #21
0
 /// <summary>
 /// Creates a new group in the specified location where the name, displayName, and 
 /// SamAccountName are the value of the name parameter.
 /// </summary>
 /// <param name="name">The new group's name, display name and SamAccountName.</param>
 /// <param name="location">The OU's distinguishedName where the new group should created.</param>
 /// <param name="description">The description of the new group.</param>
 /// <param name="scope">The GroupScope of the new group.</param>
 /// <param name="isSecurityGroup">A boolean designating the new group as a security group or not.</param>
 /// <returns>The GroupPrincipal object of the new group..</returns>
 public static GroupPrincipal CreateGroup(string name, string location, string description, GroupScope scope, bool isSecurityGroup)
 {
     GroupPrincipal newGroup = new GroupPrincipal(GetPrincipalContext(location), name);
     newGroup.GroupScope = scope;
     newGroup.IsSecurityGroup = isSecurityGroup;
     newGroup.Name = name;
     newGroup.DisplayName = name;
     newGroup.Description = description;
     newGroup.Save();
     return newGroup;
 }