コード例 #1
0
 public UserDeleteFixture(IADOperator adOperator)
 {
     _userDelete       = new UserDelete(adOperator);
     UserPrincipalName = "*****@*****.**";
     Settings          = new UserSettings {
         LoginName = "admin", Password = "******", DomainName = "test"
     };
 }
コード例 #2
0
 public UserCreateFixture(IADOperator adOperator)
 {
     _userCreate         = new UserCreate(adOperator);
     SamAccountName      = "test";
     OuDistinguishedName = "group";
     Settings            = new UserSettings {
         LoginName = "admin", Password = "******", DomainName = "test"
     };
 }
コード例 #3
0
 public UserUpdateFixture(IADOperator adOperator)
 {
     _userUpdate        = new UserUpdate(adOperator);
     AttributeName      = "employeeId";
     AttributeValue     = "1234";
     OrganizationalUnit = "test";
     Settings           = new UserSettings {
         LoginName = "admin", Password = "******", DomainName = "test"
     };
 }
コード例 #4
0
 /// <summary>
 /// The constructor with AD operator and SearchResult params.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="searchResult">The SearchResult.</param>
 internal protected ADObject(IADOperator adOperator, SearchResult searchResult)
 {
     this.ADOperator   = adOperator;
     this.SearchResult = searchResult;
     if (searchResult != null)
     {
         this.Path = searchResult.Path;
     }
     this.Type = GetADObjectType(searchResult);
 }
コード例 #5
0
        /// <summary>
        /// Find one AD object by filter and path.
        /// </summary>
        /// <param name="adOperator">The AD operator.</param>
        /// <param name="filter">The filter</param>
        /// <param name="ldapPath">The LDAP path.</param>
        /// <param name="queryScopeType">The query scope type.</param>
        /// <returns>One AD object.</returns>
        internal static TADObject FindOneByFilter <TADObject>(IADOperator adOperator, IFilter filter, string ldapPath, QueryScopeType queryScopeType) where TADObject : class
        {
            TADObject adObject;

            using (var directoryEntryRepository = new DirectoryEntryRepository(adOperator, ldapPath, queryScopeType))
            {
                adObject = GetADObject(adOperator, directoryEntryRepository.GetSearchResult(filter)) as TADObject;
            }
            return(adObject);
        }
コード例 #6
0
        /// <summary>
        /// Verify whether the AD object with the object guid exists.
        /// </summary>
        /// <param name="adOperator">The AD operator.</param>
        /// <param name="objectGuid">The AD object guid.</param>
        /// <returns>Whether the AD Object exists.</returns>
        public static bool DoesADObjectExists(IADOperator adOperator, Guid objectGuid)
        {
            bool doesADObjectExists;

            using (var objectGuidDirectoryEntryRepository = new ObjectGUIDDirectoryEntryRepository(adOperator, objectGuid))
            {
                doesADObjectExists = objectGuidDirectoryEntryRepository.Exists;
            }
            return(doesADObjectExists);
        }
コード例 #7
0
 public UserFindFixture(IADOperator adOperator)
 {
     _userFind          = new UserFind(adOperator);
     PropertyName       = "proxyAddresses";
     PropertyValue      = "*****@*****.**";
     AttributeName      = "distinguishedName";
     OrganizationalUnit = "CakeUsers";
     Settings           = new UserSettings {
         LoginName = "admin", Password = "******", DomainName = "test"
     };
 }
コード例 #8
0
        /// <summary>
        /// Find one domain object.
        /// </summary>
        /// <returns>One domain object.</returns>
        public static IList <PasswordSettingsObject> FindAll(IADOperator adOperator, string userCn)
        {
            var userObject = UserObject.FindOneByCN(adOperator, userCn);

            return(FindAllByFilter <PasswordSettingsObject>(adOperator,
                                                            new And(
                                                                new IsPasswordSettings(),
                                                                new Or(
                                                                    new Is(PSOAttributeNames.MsDS_PSOAppliesTo, userObject.DistinguishedName),
                                                                    new Is(PSOAttributeNames.MsDS_PSOAppliesTo, userObject.ObjectSid)))));
        }
コード例 #9
0
        /// <summary>
        /// Find one AD object by objectGUID.
        /// </summary>
        /// <param name="adOperator">The AD operator.</param>
        /// <param name="objectGuid">The objectGUID.</param>
        /// <returns>One AD object.</returns>
        public static ADObject FindOneByObjectGUID(IADOperator adOperator, Guid objectGuid)
        {
            ADObject adObject = null;

            using (var objectGuidDirectoryEntryRepository = new ObjectGUIDDirectoryEntryRepository(adOperator, objectGuid))
            {
                if (objectGuidDirectoryEntryRepository.Exists)
                {
                    adObject = GetADObject(adOperator, objectGuidDirectoryEntryRepository.GetSearchResult());
                }
            }
            return(adObject);
        }
コード例 #10
0
        /// <summary>
        /// Find all AD objects by filter and path.
        /// </summary>
        /// <param name="adOperator">The AD operator.</param>
        /// <param name="filter">The filter</param>
        /// <param name="ldapPath">The LDAP path.</param>
        /// <param name="queryScopeType">The query scope type.</param>
        /// <returns>All AD objects.</returns>
        internal static List <TADObject> FindAllByFilter <TADObject>(IADOperator adOperator, IFilter filter, string ldapPath, QueryScopeType queryScopeType)
        {
            List <TADObject> adObjects;

            using (var directoryEntryRepository = new DirectoryEntryRepository(adOperator, ldapPath, queryScopeType))
            {
                using (var searchResultCollection = directoryEntryRepository.GetSearchResultCollection(filter))
                {
                    var objects = (from SearchResult searchResult in searchResultCollection
                                   select GetADObject(adOperator, searchResult)).ToList();
                    adObjects = objects.Cast <TADObject>().ToList();
                }
            }
            return(adObjects);
        }
コード例 #11
0
        /// <summary>
        /// Find all AD objects by distinguished names.
        /// </summary>
        /// <param name="adOperator">The AD operator.</param>
        /// <param name="distinguishedNames">The distinguished names.</param>
        /// <returns>All AD objects.</returns>
        public static IList <ADObject> FindAllByDNs(IADOperator adOperator, IList <string> distinguishedNames)
        {
            List <ADObject> adObjects;
            var             filters = distinguishedNames.Select(distinguishedName => new Is(AttributeNames.DistinguishedName, distinguishedName)).Cast <IFilter>().ToList();

            if (filters.Count != 0)
            {
                IFilter filter = new Or(filters.ToArray());
                adObjects = FindAllByFilter <ADObject>(adOperator, filter);
            }
            else
            {
                adObjects = new List <ADObject>();
            }
            return(adObjects);
        }
コード例 #12
0
        protected override void SetUp()
        {
            this.GroupGuid           = new Guid(TF.GetConfig().Properties["GroupGuid"]);
            this.GroupCn             = TF.GetConfig().Properties["GroupCn"];
            this.GroupSid            = TF.GetConfig().Properties["GroupSid"];
            this.GroupSAMAccountName = TF.GetConfig().Properties["GroupSAMAccountName"];
            this.GroupEmail          = TF.GetConfig().Properties["GroupEmail"];
            this.GroupNotes          = TF.GetConfig().Properties["GroupNotes"];
            this.GroupTokenGroupSid  = TF.GetConfig().Properties["GroupTokenGroupSid"];
            this.GroupMember         = TF.GetConfig().Properties["GroupMember"];
            this.GroupType           = TF.GetConfig().Properties["GroupType"];
            this.GroupScope          = TF.GetConfig().Properties["GroupScope"];
            var mock           = new Mock <IADOperator>();
            var adOperatorInfo = new ADOperatorInfo
            {
                UserLoginName     = TF.GetConfig().Properties["IPDomainUserName"],
                Password          = TF.GetConfig().Properties["IPDomainUserPassword"],
                OperateDomainName = TF.GetConfig().Properties["IPDomainName"],
            };

            mock.Setup(m => m.GetOperatorInfo()).Returns(adOperatorInfo);
            this.IPADOperator = mock.Object;
        }
コード例 #13
0
        public DirectoryEntryRepository(IADOperator adOperator, string ldapPath, QueryScopeType queryScopeType)
        {
            var    adOperatorInfo = adOperator.GetOperatorInfo();
            string path;

            if (String.IsNullOrEmpty(ldapPath))
            {
                path = String.Format(@"LDAP://{0}", adOperatorInfo.OperateDomainName);
            }
            else
            {
                path = ldapPath;
            }
            if (!String.IsNullOrEmpty(adOperatorInfo.UserLoginName) && !String.IsNullOrEmpty(adOperatorInfo.Password))
            {
                this.DirectoryEntry = new DirectoryEntry(path, adOperatorInfo.UserLoginName, adOperatorInfo.Password);
            }
            else
            {
                this.DirectoryEntry = new DirectoryEntry(path);
            }
            this.QueryScopeType = queryScopeType;
        }
コード例 #14
0
        public ObjectGUIDDirectoryEntryRepository(IADOperator adOperator, Guid objectGuid)
        {
            var    adOperatorInfo = adOperator.GetOperatorInfo();
            string path           = String.Format(@"LDAP://{0}/<GUID={1}>", adOperatorInfo.OperateDomainName, objectGuid);

            try
            {
                if (!String.IsNullOrEmpty(adOperatorInfo.UserLoginName) && !String.IsNullOrEmpty(adOperatorInfo.Password))
                {
                    this.DirectoryEntry = new DirectoryEntry(path, adOperatorInfo.UserLoginName, adOperatorInfo.Password);
                }
                else
                {
                    this.DirectoryEntry = new DirectoryEntry(path);
                }
                var directoryEntryId = this.DirectoryEntry.Guid;
                this.Exists = true;
            }
            catch
            {
                this.Exists = false;
            }
        }
コード例 #15
0
        public void FixtureSetUp()
        {
            // Normal
            var mock           = new Mock <IADOperator>();
            var adOperatorInfo = new ADOperatorInfo
            {
                UserLoginName     = TF.GetConfig().Properties["DomainUserName"],
                Password          = TF.GetConfig().Properties["DomainUserPassword"],
                OperateDomainName = TF.GetConfig().Properties["DomainName"],
            };

            mock.Setup(m => m.GetOperatorInfo()).Returns(adOperatorInfo);
            this.ADOperator = mock.Object;
            // Anonymous
            var anonymousMock = new Mock <IADOperator>();

            adOperatorInfo = new ADOperatorInfo
            {
                UserLoginName     = String.Empty,
                Password          = String.Empty,
                OperateDomainName = TF.GetConfig().Properties["DomainName"],
            };
            anonymousMock.Setup(m => m.GetOperatorInfo()).Returns(adOperatorInfo);
            this.AnonymousADOperator = anonymousMock.Object;
            // Large amount
            var largeAmountMock           = new Mock <IADOperator>();
            var largeAmountADOperatorInfo = new ADOperatorInfo
            {
                UserLoginName     = TF.GetConfig().Properties["LargeAmountDomainUserName"],
                Password          = TF.GetConfig().Properties["LargeAmountDomainUserPassword"],
                OperateDomainName = TF.GetConfig().Properties["LargeAmountDomainName"],
            };

            largeAmountMock.Setup(m => m.GetOperatorInfo()).Returns(largeAmountADOperatorInfo);
            this.LargeAmountADOperator = largeAmountMock.Object;
            this.SetUp();
        }
コード例 #16
0
 /// <summary>
 /// Get the single AD object which is matched with the filter.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="filter">The root AD filter.</param>
 /// <returns>The single AD object which is matched with the filter.</returns>
 public static ADObject SingleAndDefault(IADOperator adOperator, IFilter filter)
 {
     return(ADObject.FindOneByFilter <ADObject>(adOperator, filter));
 }
コード例 #17
0
 /// <summary>
 /// Get all the AD objects which is matched with the filter.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="filter">The root AD filter.</param>
 /// <param name="ldapPath">The LDAP path.</param>
 /// <param name="queryScopeType">The query scope type<seealso cref="QueryScopeType"/>.</param>
 /// <returns>All the AD objects which is matched with the filter.</returns>
 public static IList <ADObject> List(IADOperator adOperator, IFilter filter, string ldapPath, QueryScopeType queryScopeType)
 {
     return(ADObject.FindAllByFilter <ADObject>(adOperator, filter, ldapPath, queryScopeType));
 }
コード例 #18
0
 /// <summary>
 /// Find all group objects by filter.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="filter">The filter.</param>
 /// <returns>All group objects by filter.</returns>
 public static IList <GroupObject> FindAll(IADOperator adOperator, IFilter filter)
 {
     return(FindAllByFilter <GroupObject>(adOperator, new And(new IsGroup(), filter)));
 }
コード例 #19
0
 /// <summary>
 /// Get the single AD object which is matched with the filter.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="filter">The root AD filter.</param>
 /// <param name="ldapPath">The LDAP path.</param>
 /// <param name="queryScopeType">The query scope type<seealso cref="QueryScopeType"/>.</param>
 /// <returns>The single AD object which is matched with the filter.</returns>
 public static ADObject SingleAndDefault(IADOperator adOperator, IFilter filter, string ldapPath, QueryScopeType queryScopeType)
 {
     return(ADObject.FindOneByFilter <ADObject>(adOperator, filter, ldapPath, queryScopeType));
 }
コード例 #20
0
 /// <summary>
 /// Fine one user directory entry.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="sid">The sid.</param>
 /// <returns></returns>
 public static GroupObject FindOneBySid(IADOperator adOperator, string sid)
 {
     return(FindOneByFilter <GroupObject>(adOperator, new Is(GroupAttributeNames.ObjectSid, sid)));
 }
コード例 #21
0
 /// <summary>
 /// Fine one group object by common name.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="cn">The common name.</param>
 /// <returns>One group object.</returns>
 public static GroupObject FindOneByCN(IADOperator adOperator, string cn)
 {
     return(FindOneByFilter <GroupObject>(adOperator, new And(new IsGroup(), new Is(AttributeNames.CN, cn))));
 }
コード例 #22
0
 internal GroupObject(IADOperator adOperator, SearchResult searchResult)
     : base(adOperator, searchResult)
 {
 }
コード例 #23
0
 /// <summary>
 /// Find all ou objects.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="filter">The filter.</param>
 /// <returns>All ou objects by filter.</returns>
 public static IList <OrganizationalUnitObject> FindAll(IADOperator adOperator, IFilter filter)
 {
     return(FindAllByFilter <OrganizationalUnitObject>(adOperator, new And(new IsOU(), filter)));
 }
コード例 #24
0
 /// <summary>
 /// Fine one ou object by distinguished name.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="distinguishedName">The distinguished name</param>
 /// <returns></returns>
 public static OrganizationalUnitObject FindOneByDN(IADOperator adOperator, string distinguishedName)
 {
     return(FindOneByFilter <OrganizationalUnitObject>(adOperator, new And(new IsOU(), new Is(AttributeNames.DistinguishedName, distinguishedName))));
 }
コード例 #25
0
 internal protected PackContainerObject(IADOperator adOperator, SearchResult searchResult) :
     base(adOperator, searchResult)
 {
 }
コード例 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDisable"/> class.
 /// </summary>
 /// <param name="adOperator">The Active Directory.</param>
 public UserDisable(IADOperator adOperator) : base(adOperator)
 {
 }
コード例 #27
0
 /// <summary>
 /// Fine one AD object by distinguished name.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="distinguishedName">The distinguished name.</param>
 /// <returns>One AD object.</returns>
 public static ADObject FindOneByDN(IADOperator adOperator, string distinguishedName)
 {
     return(FindOneByFilter <ADObject>(adOperator, new Is(AttributeNames.DistinguishedName, distinguishedName)));
 }
コード例 #28
0
 internal OrganizationalUnitObject(IADOperator adOperator, SearchResult searchResult)
     : base(adOperator, searchResult)
 {
 }
コード例 #29
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);
        }
コード例 #30
0
 /// <summary>
 /// Fine one ou object by ou name.
 /// </summary>
 /// <param name="adOperator">The AD operator.</param>
 /// <param name="ouName">The OU name.</param>
 /// <returns>One ou object.</returns>
 public static OrganizationalUnitObject FindOneByOU(IADOperator adOperator, string ouName)
 {
     return(FindOneByFilter <OrganizationalUnitObject>(adOperator, new And(new IsOU(), new Is(OrganizationalUnitAttributeNames.OU, ouName))));
 }