示例#1
0
        static void Main()
        {
            IActiveDirectoryService service = ActiveDirectoryServiceFactory.CreateCachedActiveDirectoryService(ConfigurationManager.AppSettings["domainPath"], TimeSpan.FromMinutes(5));

            List <IPrincipal> principals = service.SearchPrincipals("(&(objectClass=person)(sn=*)(company=*)(!userAccountControl:1.2.840.113556.1.4.803:=2)(department=*)(title=*))",
                                                                    new List <string> {
                "extensionAttribute8", "department", "company", "division"
            })
                                           .ToList();

            foreach (IPrincipal principal in principals.OrderBy(p => p.DisplayName))
            {
                Debug.WriteLine(principal.DisplayName);
            }

            List <IPrincipal> principals2 = service.SearchPrincipals("(&(objectClass=person)(sn=*)(company=*)(!userAccountControl:1.2.840.113556.1.4.803:=2)(department=*)(title=*))",
                                                                     new List <string> {
                "extensionAttribute8", "department", "company", "division"
            })
                                            .ToList();

            //IActiveDirectoryService service = ActiveDirectoryServiceFactory.CreateCachedActiveDirectoryService(ConfigurationManager.AppSettings["domainPath"],
            //    TimeSpan.FromMinutes(5));

            //Task<List<IPrincipal>> task = Task.Factory.StartNew(() => service.GetGroupMembers("turku-list", true, new List<string> { "thumbnailPhoto" }).ToList());

            //System.Threading.Thread.Sleep(2000);

            //IPrincipal principal = service.GetPrincipal("valtojoh", new List<string> { "thumbnailPhoto" });

            //List<IPrincipal> principals = service.GetGroupMembers("turku-list", true, new List<string> { }).ToList();


            ////IPrincipal principal = service.GetPrincipal("", new List<string> { });
            //bool isGroupMember = service.IsGroupMember("valtojoh", "turku-list");

            //List<IPrincipal> principals2 = service.GetGroupMembers("turku-list", true, new List<string> { }).ToList();

            //task.Wait();
        }
示例#2
0
        public IReadOnlyCollection <IEmployee> GetEmployees()
        {
            var additionalProperties = new[]
            {
                configuration.LastNameProperty,
                configuration.FirstNameProperty,
                configuration.TitleProperty,
                configuration.PictureUrlProperty,
                configuration.LocationProperty,
                configuration.OrganizationProperty,
                configuration.SubOrganizationProperty
            };

            IEnumerable <IPrincipal> principals = activeDirectoryService.SearchPrincipals(configuration.QueryFilter, additionalProperties);

            return(principalMapper.Map(principals).ToList());
        }
示例#3
0
        public void PrincipalsFromAllGroupsAreCollected()
        {
            IPrincipal member1 = Substitute.For <IPrincipal>();
            IPrincipal member2 = Substitute.For <IPrincipal>();
            IPrincipal member3 = Substitute.For <IPrincipal>();

            member1.NativeGuid.Returns(Guid.NewGuid());
            member2.NativeGuid.Returns(Guid.NewGuid());
            member3.NativeGuid.Returns(Guid.NewGuid());

            configuration.QueryFilter.Returns(QueryFilter);
            activeDirectoryService.SearchPrincipals(QueryFilter, Arg.Any <ICollection <string> >()).Returns(new List <IPrincipal> {
                member1, member2, member3
            });

            IReadOnlyCollection <IEmployee> result = sut.GetEmployees();

            Assert.AreEqual(3, result.Count);
        }