public ActionResult Index() { ADDomain domain = new ADDomain(); ViewUsersVM users = new ViewUsersVM(); users.RecentlyCreated = domain.GetUsersByCriteria(AdvancedSearchFilter.DateCreated, DateTime.Now.AddDays(-7)).Take(10).ToList(); return(View(users)); }
private IRecipientSession CreateWriteableRecipientSessionForRootDomain() { ADDomain addomain = ADForest.GetLocalForest().FindRootDomain(true); if (addomain == null) { base.ThrowTerminatingError(new RootDomainNotFoundException(), ErrorCategory.InvalidData, null); } return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(addomain.OriginatingServer, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 382, "CreateWriteableRecipientSessionForRootDomain", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\UpdateRmsSharedIdentity.cs")); }
public PartialViewResult RefreshRecentlyCreated(int days = 7) { int formattedDays = days * (-1); ADDomain domain = new ADDomain(); List <ADUser> users = domain.GetUsersByCriteria(AdvancedSearchFilter.DateCreated, DateTime.Now.AddDays(formattedDays)).ToList(); users.OrderBy(u => u.WhenCreated); return(PartialView("_FilteredUsers", users)); }
public ActionResult ViewGroup(string group) { ADDomain domain = new ADDomain(); ADGroup groupInfo = domain.GetGroupByName(group); ViewGroupVM groupVM = Mapper.Map <ViewGroupVM>(groupInfo); groupVM.OldGroupName = groupInfo.GroupName; return(View(groupVM)); }
public static void GetComputers() { Domain domain = Domain.GetCurrentDomain(); var d = new ADDomain(domain.Name.ToString()); foreach (ADComputer c in d.GetADComputers()) { Console.WriteLine(c.GroupName + ", " + c.DistinguishedName); } }
public static void GetAllGroups() { Domain domain = Domain.GetCurrentDomain(); var d = new ADDomain(domain.Name.ToString()); foreach (ADGroup g in d.GetAllGroups()) { Console.WriteLine($"{g.GroupName}, {g.DistinguishedName}"); } }
public ActionResult CreateUser(CreateUserVM user) { if (ModelState.IsValid) { using (var db = new ADWebDB()) { ADWeb.Core.Models.User newUser = Mapper.Map <User>(user); ADDomain domain = new ADDomain(); // Get User Template Settings so that we can use it to create // the user. UserTemplate userTemplate = db.UserTemplate .Find(user.UserTemplateID); UserTemplateSettings userTemplateSettings = new UserTemplateSettings(); userTemplateSettings.ChangePasswordAtNextLogon = userTemplate.ChangePasswordAtNextLogon; userTemplateSettings.UserCannotChangePassword = userTemplate.UserCannotChangePassword; userTemplateSettings.PasswordNeverExpires = userTemplate.PasswordNeverExpires; userTemplateSettings.AccountExpires = userTemplate.AccountExpires; userTemplateSettings.ExpirationRange = userTemplate.ExpirationRange; userTemplateSettings.ExpirationValue = userTemplate.ExpirationValue; userTemplateSettings.DomainOU = userTemplate.DomainOU.DistinguishedName; // When getting the groups associated with a user template, we // are only interested in getting those groups that are active (i.e. // they have not been removed by the admins of the application). If this is // not done, then there will be an error if a group happens to have been // added, removed and then added again by one of the administrators. This should // be a rare occurrance, but we have to check just to make sure no errors occur // when creating user accounts. foreach (var group in userTemplate.Groups.Where(u => u.Enabled == true).ToList()) { userTemplateSettings.Groups.Add(group.Name); } domain.CreateUserWithTemplate(newUser, userTemplateSettings); ADUser currentUser = domain.GetUserByID(User.Identity.Name); // Insert the account to the Database. Note: we are only // interested in basic information DomainUser newDomainUser = new DomainUser(); newDomainUser.DateCreated = DateTime.Now; newDomainUser.CreatedBy = currentUser.GivenName + " " + currentUser.Surname; newDomainUser.Username = newUser.Username; db.DomainUsers.Add(newDomainUser); db.SaveChanges(); TempData["user_created_successfully"] = newUser.FirstName + " " + newUser.LastName + " has been created successfully!"; return(RedirectToAction("ViewUser", new { user = user.Username })); } } return(View()); }
public async Task GetRsopOfReachableComputersAndCheckSysmon(string serviceName) { if (string.IsNullOrEmpty(serviceName)) { serviceName = "Sysmon"; } clearOldRsops(); List <OrganizationalUnit> allOUs = await unitOfWork.OrganizationalUnitRepository.GetAllEntities(); List <ADDomain> allDomains = await unitOfWork.ADDomainRepository.GetAllEntities(); List <int?> collectedSiteIds = new List <int?>(); string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; foreach (OrganizationalUnit OU in allOUs) { collectedSiteIds.Clear(); ADDomain domain = allDomains.Find(x => x.ADDomainId == OU.ADDomainRefId); string domainName = domain.Name; if (OU.Computers != null) { OU.HasReachableComputer = false; foreach (var computer in OU.Computers) { if (pingService.IsPingable(computer.IpAddress)) { if (!collectedSiteIds.Contains(computer.SiteRefId)) { computer.PingSuccessful = true; OU.HasReachableComputer = true; unitOfWork.OrganizationalUnitRepository.Update(OU); collectedSiteIds.Add(computer.SiteRefId); getRSoP(computer.ComputerName + "." + domainName, OU.OrganizationalUnitsId, computer.SiteRefId, user); } computer.isSysmonRunning = sysmonService.IsSysmonRunning(serviceName, user, computer.ComputerName, domainName); unitOfWork.ComputerRepository.Update(computer); } } await unitOfWork.SaveChangesAsync(); } } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); IConfigurationSession configurationSession = base.DataSession as IConfigurationSession; if (this.Identity != null) { this.Identity.IncludeContainers = this.IncludeContainers; if (this.SingleNodeOnly) { IConfigurable dataObject = base.GetDataObject(this.Identity); base.WriteResult(dataObject); IEnumerable <ExtendedOrganizationalUnit> dataObjects = ExtendedOrganizationalUnit.FindFirstLevelChildOrganizationalUnit(this.IncludeContainers, configurationSession, dataObject.Identity as ADObjectId, this.InternalFilter, this.InternalSortBy, this.PageSize); base.WriteResult <ExtendedOrganizationalUnit>(dataObjects); } else { base.InternalProcessRecord(); } } else { if (this.SingleNodeOnly) { if (this.IsTenant) { ExtendedOrganizationalUnit dataObject2 = configurationSession.Read <ExtendedOrganizationalUnit>((ADObjectId)this.RootId); this.WriteResult(dataObject2); goto IL_195; } ReadOnlyCollection <ADDomain> readOnlyCollection = ADForest.GetLocalForest(configurationSession.DomainController).FindTopLevelDomains(); using (ReadOnlyCollection <ADDomain> .Enumerator enumerator = readOnlyCollection.GetEnumerator()) { while (enumerator.MoveNext()) { ADDomain addomain = enumerator.Current; ExtendedOrganizationalUnit dataObject3 = configurationSession.Read <ExtendedOrganizationalUnit>(addomain.Id); this.WriteResult(dataObject3); } goto IL_195; } } IEnumerable <ExtendedOrganizationalUnit> enumerable = ExtendedOrganizationalUnit.FindSubTreeChildOrganizationalUnit(this.IncludeContainers, configurationSession, this.IsTenant ? ((ADObjectId)this.RootId) : null, this.InternalFilter); if (!string.IsNullOrEmpty(this.SearchText)) { string nameToSearch = this.SearchText.ToUpper(); enumerable = from ou in enumerable where ou.CanonicalName.ToUpper().Contains(nameToSearch) select ou; } this.WriteResult <ExtendedOrganizationalUnit>(enumerable); } IL_195: TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); ADForest adforest; if (this.Forest == null) { adforest = ADForest.GetLocalForest(); } else { adforest = ADForest.GetForest(this.Forest, this.Credential); } List <ADServer> list = new List <ADServer>(); if (this.GlobalCatalog) { list.AddRange(adforest.FindAllGlobalCatalogs(false)); } else { if (this.DomainName == null) { using (ReadOnlyCollection <ADDomain> .Enumerator enumerator = adforest.FindDomains().GetEnumerator()) { while (enumerator.MoveNext()) { ADDomain addomain = enumerator.Current; list.AddRange(addomain.FindAllDomainControllers(false)); } goto IL_F3; } } ADDomain addomain2; if (this.Credential == null) { addomain2 = adforest.FindDomainByFqdn(this.DomainName.ToString()); } else { addomain2 = ADForest.FindExternalDomain(this.DomainName.ToString(), this.Credential); } if (addomain2 != null) { list.AddRange(addomain2.FindAllDomainControllers(false)); } else { base.WriteError(new DomainNotFoundException(this.DomainName.ToString()), ErrorCategory.InvalidArgument, null); } } IL_F3: this.WriteResult <ADServer>(list); TaskLogger.LogExit(); }
private void AddSessionsFromDomain(ADDomain domain) { foreach (string replicaDirectoryServer in domain.ReplicaDirectoryServers) { this._sessionPipe.AddLast(new ADSessionInfo(replicaDirectoryServer)); } foreach (string readOnlyReplicaDirectoryServer in domain.ReadOnlyReplicaDirectoryServers) { this._sessionPipe.AddLast(new ADSessionInfo(readOnlyReplicaDirectoryServer)); } }
public static ADGroup GetDNSAdmins(ADDomain dom, IConfigurationSession session) { if (dom == null || session == null) { return(null); } ADObjectId[] ids = new ADObjectId[] { new ADObjectId("CN=DnsAdmins,CN=Users," + dom.DistinguishedName) }; return(session.FindByADObjectIds <ADGroup>(ids)[0].Data); }
public ActionResult IsGroupnameUnique(string groupName) { if (!string.IsNullOrEmpty(groupName)) { ADDomain domain = new ADDomain(); bool isGroupFound = domain.IsGroupnameUnique(groupName); return(Json(isGroupFound, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult QuickSearch(SearchUsersModel model) { if (ModelState.IsValid) { ADDomain domain = new ADDomain(); List <ADUser> users = domain.QuickSearch(model.SearchValue); ViewBag.SearchValue = model.SearchValue; return(View("SearchResults", users)); } return(View(model)); }
private static TreeNode NewDomainNode(ADDomain domain) { return(new TreeNode { Description = "Domain: ", IsRSoP = false, TypeRefIdDictionary = new Dictionary <string, int> { { "Domain", domain.ADDomainId } }, Identifier = domain.Name, AnalysisPercentage = domain.DomainPercentage ?? 0.0 }); }
public ActionResult Index() { ADDomain domain = new ADDomain(); ViewUsersVM users = new ViewUsersVM(); // by default, we will take up to 10 of the recently created users // should this be a db setting? users.RecentlyCreated = domain.GetUsersByCriteria(AdvancedSearchFilter.DateCreated, DateTime.Now.AddDays(-7)) .Take(10) .ToList(); return(View(users)); }
public static void Authenticate(string username, string password) { Domain domain = Domain.GetCurrentDomain(); var d = new ADDomain(domain.Name.ToString()); if (d.IsValidLogin(username, password) == true) { Console.WriteLine("The logon is valid."); } else { Console.WriteLine("The logon is invalid."); } }
public static void IsADUser() { Domain domain = Domain.GetCurrentDomain(); var d = new ADDomain(domain.Name.ToString()); if (d.IsADAccount("ryan") == true) { Console.WriteLine("The account exists."); } else { Console.WriteLine("The account does not exist."); } }
public ActionResult Index() { if (User.Identity.IsAuthenticated) { ADDomain domain = new ADDomain(); // By default, we'll show the user the accounts that // were created in the last 7 days. List <ADUser> users = domain.GetUsersByCriteria(AdvancedSearchFilter.DateCreated, DateTime.Now.AddDays(-7)).Take(10).ToList(); ViewBag.UsersChanged = users; } return(View()); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); AvailabilityConfig availabilityConfig = null; IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession; ADObjectId orgContainerId = configurationSession.GetOrgContainerId(); configurationSession.SessionSettings.IsSharedConfigChecked = true; AvailabilityConfig[] array = configurationSession.Find <AvailabilityConfig>(orgContainerId, QueryScope.SubTree, ADObject.ObjectClassFilter("msExchAvailabilityConfig"), null, 1); if (array != null && array.Length == 1) { availabilityConfig = array[0]; } if (availabilityConfig == null) { availabilityConfig = (AvailabilityConfig)base.PrepareDataObject(); } availabilityConfig.Name = AvailabilityConfig.ContainerName; availabilityConfig.SetId((IConfigurationSession)base.DataSession, availabilityConfig.Name); availabilityConfig.OrgWideAccount = this.ValidateUser((SecurityPrincipalIdParameter)base.Fields["OrgWideAccount"]); ADDomain addomain = ADForest.GetLocalForest().FindRootDomain(true); if (addomain == null) { base.ThrowTerminatingError(new RootDomainNotFoundException(), ErrorCategory.InvalidData, null); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(addomain.OriginatingServer, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 105, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs"); IConfigurationSession configurationSession2 = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 111, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs"); this.exchangeServerGroup = null; try { this.exchangeServerGroup = tenantOrRootOrgRecipientSession.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, configurationSession2.ConfigurationNamingContext); } catch (ADReferralException) { } if (this.exchangeServerGroup == null) { IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 131, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs"); tenantOrRootOrgRecipientSession2.UseGlobalCatalog = true; this.exchangeServerGroup = tenantOrRootOrgRecipientSession2.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, configurationSession2.ConfigurationNamingContext); } if (this.exchangeServerGroup == null) { base.ThrowTerminatingError(new ExSGroupNotFoundException(WellKnownGuid.ExSWkGuid), ErrorCategory.InvalidData, null); } TaskLogger.LogExit(); return(availabilityConfig); }
private void Initialize() { ADDomain addomain = this.targetSession.Read <ADDomain>(this.syncConfigData.Target.PartitionRoot); this.targetDomainSid = addomain.Sid; this.wellKnownExchangeSecurityPrincipals = new HashSet <SecurityIdentifier>(); ADObjectId childId = this.syncConfigData.Source.PartitionRoot.GetChildId("OU", "Microsoft Exchange Security Groups"); ADRawEntry[] array = this.sourceSession.Find(childId, QueryScope.OneLevel, this.groupFilter, null, 0, this.groupProperties); foreach (ADRawEntry adrawEntry in array) { this.wellKnownExchangeSecurityPrincipals.Add((SecurityIdentifier)adrawEntry[ADMailboxRecipientSchema.Sid]); } }
public static bool InLocalDomain(ADServer server) { ADDomain addomain = ADForest.GetLocalForest().FindLocalDomain(); if (addomain == null || addomain.Id == null) { throw new ADInitializationException(Strings.LocalDomainNotFoundException); } if (server.DomainId == null) { throw new ADInitializationException(Strings.ServerDoesNotHaveADomain(server.Name)); } return(server.DomainId.Equals(addomain.Id)); }
private bool IsTopLevelDomain(string domainFqdn) { bool result = false; foreach (object obj in this.topLevelDomains) { ADDomain addomain = (ADDomain)obj; if (string.Equals(domainFqdn, addomain.Fqdn, StringComparison.InvariantCultureIgnoreCase)) { result = true; break; } } return(result); }
public ActionResult CreateGroup(CreateGroupVM group) { if (ModelState.IsValid) { Group newGroup = Mapper.Map <Group>(group); ADDomain domain = new ADDomain(); domain.CreateGroup(newGroup); TempData["group_created_successfully"] = newGroup.GroupName + " has been created successfully!"; return(RedirectToAction("ViewGroup", new { group = newGroup.GroupName })); } return(View()); }
public static ADContainer GetAdminSDHolder(ADDomain dom, IConfigurationSession session) { ExchangeOrganizationalUnit exchangeOrganizationalUnit = session.ResolveWellKnownGuid <ExchangeOrganizationalUnit>(WellKnownGuid.SystemWkGuid, dom.DistinguishedName); if (exchangeOrganizationalUnit == null) { throw new SystemContainerNotFoundException(dom.Fqdn, WellKnownGuid.SystemWkGuid); } ADContainer adcontainer = session.Read <ADContainer>(exchangeOrganizationalUnit.Id.GetChildId("AdminSDHolder")); if (adcontainer == null) { throw new AdminSDHolderNotFoundException(exchangeOrganizationalUnit.DistinguishedName); } return(adcontainer); }
private List <RsopPot> GetRsopPotsOfDomain(ADDomain domain) { var rsopsOfDomain = domain.Rsops; var rsopPots = new HashSet <RsopPot>(); if (rsopsOfDomain != null) { foreach (var rsop in rsopsOfDomain) { rsopPots.Add(unitOfWork.RsopPotRepository.GetByID(rsop.RsopPotRefId)); } rsopPots.Remove(null); } return(rsopPots.ToList()); }
public static ExDateTime GetPasswordExpirationDate(ADObjectId adUserObjectId, IRecipientSession recipientSession) { if (adUserObjectId.IsNullOrEmpty()) { throw new ArgumentException("ADUser object ID cannot be null or empty", "adUserObjectId"); } ADUser aduser = recipientSession.Read(adUserObjectId) as ADUser; if (aduser == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } if ((aduser.UserAccountControl & UserAccountControlFlags.DoNotExpirePassword) != UserAccountControlFlags.None) { return(ExDateTime.MaxValue); } ExDateTime?exDateTime = null; if (aduser.PasswordLastSet != null) { exDateTime = new ExDateTime?(new ExDateTime(ExTimeZone.UtcTimeZone, aduser.PasswordLastSet.Value)); } if (exDateTime == null) { return(ExDateTime.MaxValue); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(adUserObjectId.GetPartitionId()), 86, "GetPasswordExpirationDate", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\DirectoryHelper.cs"); tenantOrTopologyConfigurationSession.UseConfigNC = false; ADDomain addomain = tenantOrTopologyConfigurationSession.Read <ADDomain>(aduser.Id.DomainId); if (addomain == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } EnhancedTimeSpan?maximumPasswordAge = addomain.MaximumPasswordAge; TimeSpan? timeSpan = (maximumPasswordAge != null) ? new TimeSpan?(maximumPasswordAge.GetValueOrDefault()) : null; if (timeSpan == null || timeSpan == TimeSpan.Zero) { return(ExDateTime.MaxValue); } return(exDateTime.Value.Add(timeSpan.Value)); }
public static ADServer PickLocalDomainController() { ADServer adserver = DirectoryUtilities.DomainControllerFromName("localhost"); if (adserver != null && DirectoryUtilities.IsGlobalCatalog(adserver) && adserver.IsAvailable()) { return(adserver); } ADSite localSite = DirectoryUtilities.ConfigurationSession.GetLocalSite(); if (localSite == null) { throw new ADInitializationException(Strings.LocalSiteNotFound); } ADDomain addomain = ADForest.GetLocalForest().FindLocalDomain(); if (addomain == null) { throw new ADInitializationException(Strings.LocalDomainNotFoundException); } ReadOnlyCollection <ADServer> readOnlyCollection = addomain.FindAllDomainControllers(); foreach (ADServer adserver2 in readOnlyCollection) { if (adserver2.ValidateRead().Length == 0 && adserver2.Site.Equals(localSite.Id) && adserver2.IsAvailable() && DirectoryUtilities.IsGlobalCatalog(adserver2)) { return(adserver2); } } if (adserver != null) { return(adserver); } foreach (ADServer adserver3 in readOnlyCollection) { if (adserver3.ValidateRead().Length == 0 && adserver3.Site.Equals(localSite.Id) && adserver3.IsAvailable()) { return(adserver3); } } throw new ADInitializationException(Strings.NoDCsAvailableException(addomain.Name, localSite.Name)); }
public static bool IsLocalDomainConfigUpToDate() { bool result = false; bool flag = false; int num = 0; ADDomain addomain = ADForest.GetLocalForest().FindLocalDomain(); if (addomain == null) { throw new ADInitializationException(Strings.LocalDomainNotFoundException); } ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 531, "IsLocalDomainConfigUpToDate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\DirectoryUtilities.cs"); topologyConfigurationSession.UseConfigNC = false; MesoContainer mesoContainer = topologyConfigurationSession.FindMesoContainer(addomain); if (mesoContainer != null) { flag = true; ValidationError validationError; if (!DirectoryUtilities.IsPropertyValid(mesoContainer, MesoContainerSchema.ObjectVersion, out validationError)) { throw new ADInitializationException(Strings.MesoVersionInvalidException(validationError.Description)); } num = mesoContainer.ObjectVersion; } if (flag && num >= MesoContainer.DomainPrepVersion) { topologyConfigurationSession.UseGlobalCatalog = true; ADGroup adgroup = topologyConfigurationSession.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, topologyConfigurationSession.ConfigurationNamingContext); topologyConfigurationSession.UseGlobalCatalog = false; if (adgroup != null) { ActiveDirectoryAccessRule activeDirectoryAccessRule = new ActiveDirectoryAccessRule(adgroup.Sid, ActiveDirectoryRights.DeleteTree, AccessControlType.Deny, ActiveDirectorySecurityInheritance.All); result = DirectoryCommon.FindAces(mesoContainer, new ActiveDirectoryAccessRule[] { activeDirectoryAccessRule }); } } return(result); }
public static ADGroup GetWellKnownGroup(Guid groupGuid, IConfigurationSession configSession, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate, out IRecipientSession recipSession, out ITopologyConfigurationSession gcSession) { TaskLogger.LogEnter(); ADGroup adgroup = null; recipSession = null; recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 530, "GetWellKnownGroup", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Transport\\ManageSendConnectors.cs"); try { recipSession.UseGlobalCatalog = true; adgroup = recipSession.ResolveWellKnownGuid<ADGroup>(groupGuid, configSession.ConfigurationNamingContext); recipSession.UseGlobalCatalog = false; adgroup = (ADGroup)recipSession.Read(adgroup.Id); } finally { recipSession.UseGlobalCatalog = false; } if (adgroup == null) { try { ADDomain addomain = ADForest.GetLocalForest().FindRootDomain(true); if (addomain != null) { recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(addomain.OriginatingServer, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 564, "GetWellKnownGroup", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Transport\\ManageSendConnectors.cs"); adgroup = recipSession.ResolveWellKnownGuid<ADGroup>(groupGuid, configSession.ConfigurationNamingContext); } } catch (ADReferralException) { } } if (adgroup == null) { throwDelegate(new ErrorExchangeGroupNotFoundException(groupGuid), ErrorCategory.ObjectNotFound, null); } gcSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 589, "GetWellKnownGroup", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Transport\\ManageSendConnectors.cs"); gcSession.UseConfigNC = false; gcSession.UseGlobalCatalog = true; TaskLogger.LogExit(); return adgroup; }
public ADDomain[] GetADDomains() { System.Collections.ArrayList alTemp = new System.Collections.ArrayList(); ADDomain[] aReturn = (ADDomain[])Array.CreateInstance(typeof(ADDomain), 0); System.Data.IDataReader drReader = null; try { //----- Make sure connection is established and open. if (m_sConnState == ConnectionState.Open.ToString()) { //----- Check if SQL. if (IsDbSql() && m_sqlConn != null) { System.Data.SqlClient.SqlCommand sqlCommand = null; sqlCommand = m_sqlConn.CreateCommand(); sqlCommand.CommandText = QUERY_AD_DOMAINS; drReader = sqlCommand.ExecuteReader(); while (drReader.Read()) { ADDomain dTemp = new ADDomain(); dTemp.ID = Convert.ToInt32(drReader["ad_domain_tbl_id"]); dTemp.DomainShortName = Convert.ToString(drReader["domain_short_name"]); dTemp.DomainPath = Convert.ToString(drReader["domain_path"]); dTemp.DomainDNS = Convert.ToString(drReader["domain_dns"]); dTemp.NetBIOS = Convert.ToString(drReader["netbios"]); dTemp.Username = Convert.ToString(drReader["username"]); dTemp.Password = Convert.ToString(drReader["password"]); dTemp.ServerIP = Convert.ToString(drReader["server_ip"]); alTemp.Add(dTemp); } if (sqlCommand != null) sqlCommand = null; } //if (IsDbOracle() && m_oracleConn != null) //{ // System.Data.OracleClient.OracleCommand oracleCommand = null; // oracleCommand = m_oracleConn.CreateCommand(); // oracleCommand.CommandText = QUERY_AD_DOMAINS; // drReader = oracleCommand.ExecuteReader(); // while (drReader.Read()) // { // ADDomain dTemp = new ADDomain(); // dTemp.ID = Convert.ToInt32(drReader["ad_domain_tbl_id"]); // dTemp.DomainShortName = Convert.ToString(drReader["domain_short_name"]); // dTemp.DomainPath = Convert.ToString(drReader["domain_path"]); // dTemp.DomainDNS = Convert.ToString(drReader["domain_dns"]); // dTemp.NetBIOS = Convert.ToString(drReader["netbios"]); // dTemp.Username = Convert.ToString(drReader["username"]); // dTemp.Password = Convert.ToString(drReader["password"]); // dTemp.ServerIP = Convert.ToString(drReader["server_ip"]); // alTemp.Add(dTemp); // } // if (oracleCommand != null) // oracleCommand = null; //} if (alTemp.Count > 0) { aReturn = (ADDomain[])alTemp.ToArray(typeof(ADDomain)); } } } catch (Exception exThrown) { m_sLastError = exThrown.Message; } finally { alTemp = null; if (drReader != null) { drReader.Close(); drReader = null; } } return aReturn; }
private void ProcessDomains() { int iLength = 0; ADDomain adTMP = null; ArrayList alDomainList = new ArrayList(); ADDomain[] aRet = (ADDomain[])Array.CreateInstance(typeof(ADDomain), 0); iLength = System.Convert.ToInt32(Request.Form["Domainlength"]); if (iLength > 0) { for (int i = 0; i <= (iLength - 1); i++) { string[] aDName; adTMP = new ADDomain(); adTMP.ID = EkFunctions.ReadLongValue(Request.Form["domain_iden" + i.ToString()], 0); //adTMP.DomainShortName = Request.Form("domain_name" & i.ToString()) adTMP.DomainDNS = Request.Form["domain_dns" + i.ToString()]; aDName = adTMP.DomainDNS.Split('.'); if (aDName.Length > 0) { // use first adTMP.DomainShortName = aDName[0]; } else { adTMP.DomainShortName = adTMP.DomainDNS; } adTMP.DomainPath = Ektron.Cms.Common.EkConstants.CreateADsPathFromDomain(adTMP.DomainDNS); if (!string.IsNullOrEmpty(Request.Form["use_name" + i.ToString()])) { adTMP.NetBIOS = adTMP.DomainShortName; } else { if (!string.IsNullOrEmpty(Request.Form["netbios" + i.ToString()])) { adTMP.NetBIOS = Request.Form["netbios" + i.ToString()]; } else { adTMP.NetBIOS = adTMP.DomainShortName; } } adTMP.Username = Request.Form["user_name" + i.ToString()]; adTMP.Password = (string)(Request.Form["password" + i.ToString()].Trim()); adTMP.ServerIP = Request.Form["server_ip" + i.ToString()]; alDomainList.Add(adTMP); } aRet = (ADDomain[])alDomainList.ToArray(typeof(ADDomain)); } eUser.UpdateDomainsAdvanced(aRet); Response.Redirect("ADDomains.aspx", false); }