Ejemplo n.º 1
0
        public void TestDomain()
        {
            using (Domain domain = Domain.GetDomain(ActiveDirectoryContext))
            {
                Assert.Equal(domain.Forest.Name, Forest.GetForest(ActiveDirectoryContext).Name);
                Assert.NotNull(domain.Children);

                DomainControllerCollection domainControllers = domain.DomainControllers;
                Assert.True(domainControllers.Contains(domain.PdcRoleOwner));
                Assert.True(domainControllers.IndexOf(domain.RidRoleOwner) >= 0);
                Assert.True(domainControllers.Contains(domain.InfrastructureRoleOwner));

                Assert.True(domain.DomainModeLevel >= 0);

                Assert.True(
                    domain.DomainMode == DomainMode.Unknown ||
                    domain.DomainMode == DomainMode.Windows2000MixedDomain ||
                    domain.DomainMode == DomainMode.Windows2000NativeDomain ||
                    domain.DomainMode == DomainMode.Windows2003Domain ||
                    domain.DomainMode == DomainMode.Windows2003InterimDomain ||
                    domain.DomainMode == DomainMode.Windows2008Domain ||
                    domain.DomainMode == DomainMode.Windows2008R2Domain ||
                    domain.DomainMode == DomainMode.Windows2012R2Domain ||
                    domain.DomainMode == DomainMode.Windows8Domain);

                if (domain.Forest.RootDomain.Name.Equals(domain.Name))
                {
                    Assert.Null(domain.Parent);
                }

                Assert.Throws <ArgumentNullException>(() => domain.GetSidFilteringStatus(null));
                Assert.Throws <ArgumentException>(() => domain.GetSidFilteringStatus(""));
            }
        }
Ejemplo n.º 2
0
        public void TestDomainController()
        {
            using (Domain domain = Domain.GetDomain(ActiveDirectoryContext))
            {
                DirectoryContext dc = new DirectoryContext(
                    DirectoryContextType.Domain,
                    domain.Name,
                    LdapConfiguration.Configuration.UserName,
                    LdapConfiguration.Configuration.Password);

                using (DomainController controller = DomainController.FindOne(dc))
                {
                    using (Forest forest = Forest.GetForest(ActiveDirectoryContext))
                    {
                        Assert.Equal(forest.Name, controller.Forest.Name);
                    }

                    DomainControllerCollection dcc = DomainController.FindAll(dc);
                    Assert.True(dcc.Contains(controller));
                    Assert.True(dcc.IndexOf(controller) >= 0);

                    Assert.Equal(domain.Name, controller.Domain.Name);

                    Assert.True(controller.CurrentTime > DateTime.Today.AddDays(-2));

                    Assert.True(controller.HighestCommittedUsn > 0);

                    Assert.NotNull(controller.InboundConnections);
                    Assert.NotNull(controller.OutboundConnections);

                    foreach (ActiveDirectoryRole adr in controller.Roles)
                    {
                        Assert.True(
                            adr == ActiveDirectoryRole.InfrastructureRole ||
                            adr == ActiveDirectoryRole.NamingRole ||
                            adr == ActiveDirectoryRole.PdcRole ||
                            adr == ActiveDirectoryRole.RidRole ||
                            adr == ActiveDirectoryRole.SchemaRole);

                        Assert.True(controller.Roles.Contains(adr));
                        Assert.True(controller.Roles.IndexOf(adr) >= 0);
                    }

                    Assert.NotNull(controller.SiteName);

                    Assert.True(controller.OSVersion.IndexOf("Windows", StringComparison.OrdinalIgnoreCase) >= 0);
                    Assert.True(controller.IPAddress.IndexOf('.') >= 0);
                }
            }
        }