/// <summary>
        /// Add Group.
        /// </summary>
        /// <param name="groupName">Group name.</param>
        /// <returns>Group object.</returns>
        public GroupObject AddGroup(string groupName)
        {
            var groupDirectoryEntry = this.DirectoryEntry.Children.Add(String.Format(@"{0}={1}", AttributeNames.CN, groupName), GroupAttributeValues.Group);

            groupDirectoryEntry.CommitChanges();
            return(GroupObject.FindOneByCN(this.ADOperator, groupName));
        }
Ejemplo n.º 2
0
        internal static ADObject GetADObject(IADOperator adOperator, SearchResult searchResult)
        {
            ADObject     adObject;
            ADObjectType adObjectType = GetADObjectType(searchResult);

            switch (adObjectType)
            {
            case ADObjectType.User:
                adObject = new UserObject(adOperator, searchResult);
                break;

            case ADObjectType.Contact:
                adObject = new ContactObject(adOperator, searchResult);
                break;

            case ADObjectType.Computer:
                adObject = new ComputerObject(adOperator, searchResult);
                break;

            case ADObjectType.Container:
                adObject = new ContainerObject(adOperator, searchResult);
                break;

            case ADObjectType.Group:
                adObject = new GroupObject(adOperator, searchResult);
                break;

            case ADObjectType.InetOrgPerson:
                adObject = new InetOrgPersonObject(adOperator, searchResult);
                break;

            case ADObjectType.MSMQQueueAlias:
                adObject = new MSMQQueueAliasObject(adOperator, searchResult);
                break;

            case ADObjectType.MsImaging_PSPs:
                adObject = new MsImaging_PSPsObject(adOperator, searchResult);
                break;

            case ADObjectType.OrganizationalUnit:
                adObject = new OrganizationalUnitObject(adOperator, searchResult);
                break;

            case ADObjectType.Printer:
                adObject = new PrinterObject(adOperator, searchResult);
                break;

            case ADObjectType.SharedFolder:
                adObject = new SharedFolderObject(adOperator, searchResult);
                break;

            case ADObjectType.Domain:
                adObject = new DomainObject(adOperator, searchResult);
                break;

            case ADObjectType.PasswordSettings:
                adObject = new PasswordSettingsObject(adOperator, searchResult);
                break;

            default:
                adObject = new UnknownObject(adOperator, searchResult);
                break;
            }
            return(adObject);
        }