internal override IEnumerable <T> PerformSearch <T>(QueryFilter filter, ADObjectId rootId, IDirectorySession session, bool deepSearch) { TaskLogger.LogEnter(); if (!typeof(ExtendedOrganizationalUnit).IsAssignableFrom(typeof(T))) { throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type"); } if (session == null) { throw new ArgumentNullException("session"); } bool useGlobalCatalog = session.UseGlobalCatalog; bool useConfigNC = session.UseConfigNC; IEnumerable <T> result = null; try { session.UseGlobalCatalog = true; session.UseConfigNC = false; result = (deepSearch ? ((IEnumerable <T>)ExtendedOrganizationalUnit.FindSubTreeChildOrganizationalUnit(this.IncludeContainers, (IConfigurationSession)session, rootId, filter)) : ((IEnumerable <T>)ExtendedOrganizationalUnit.FindFirstLevelChildOrganizationalUnit(this.IncludeContainers, (IConfigurationSession)session, rootId, filter, null, 0))); } finally { session.UseGlobalCatalog = useGlobalCatalog; session.UseConfigNC = useConfigNC; } TaskLogger.LogExit(); return(result); }
public PowerShellResults <AdminRoleGroupRow> NewObject(NewAdminRoleGroupParameter properties) { properties.FaultIfNull(); PowerShellResults <AdminRoleGroupRow> powerShellResults = new PowerShellResults <AdminRoleGroupRow>(); if (properties.IsScopeModified) { if (properties.IsOrganizationalUnit) { if (string.IsNullOrEmpty(properties.ManagementScopeId)) { throw new FaultException(Strings.InvalidOrganizationalUnit(properties.ManagementScopeId)); } OrganizationalUnits organizationalUnits = new OrganizationalUnits(); Identity identity = new Identity(properties.ManagementScopeId, properties.ManagementScopeId); PowerShellResults <ExtendedOrganizationalUnit> powerShellResults2 = powerShellResults.MergeErrors <ExtendedOrganizationalUnit>(organizationalUnits.GetObject(identity)); if (powerShellResults.Failed) { return(powerShellResults); } ExtendedOrganizationalUnit value = powerShellResults2.Value; properties.RecipientOrganizationalUnitScope = new Identity(value.Id, value.Name); } else { PowerShellResults <ManagementScopeRow> managementScope = this.GetManagementScope(properties.ManagementScopeId, powerShellResults); if (powerShellResults.Failed) { return(powerShellResults); } if (managementScope != null && managementScope.SucceededWithValue) { ManagementScopeRow value2 = managementScope.Value; if (value2.ScopeRestrictionType == ScopeRestrictionType.RecipientScope) { properties.RecipientWriteScope = value2.Identity; } else if (value2.ScopeRestrictionType == ScopeRestrictionType.ServerScope) { properties.ConfigWriteScope = value2.Identity; } } } } powerShellResults = base.NewObject <AdminRoleGroupRow, NewAdminRoleGroupParameter>("New-RoleGroup", properties); if (powerShellResults.Succeeded && powerShellResults.HasWarnings) { powerShellResults.Warnings = null; } return(powerShellResults); }
public IOrganizationalUnit GetOrganizationalUnit() { SessionParameters sessionParameters = new SessionParameters(); sessionParameters.Set("SingleNodeOnly", true); ExtendedOrganizationalUnit extendedOrganizationalUnit = base.RemotePowershellSession.RunOneCommandSingleResult <ExtendedOrganizationalUnit>("Get-OrganizationalUnit", sessionParameters, true); if (extendedOrganizationalUnit != null) { return(new OrganizationalUnit { Name = extendedOrganizationalUnit.Name }); } return(null); }
public OrganizationalUnitIdParameter(ExtendedOrganizationalUnit organizationalUnit) : base(organizationalUnit.Id) { }
public static Identity ToIdentity(this ExtendedOrganizationalUnit ou) { return(ou.Id.ToIdentity(ou.CanonicalName)); }
private SetManagementRoleAssignment SetScopeInfoInParameter(Identity roleIdentity, SetManagementRoleAssignment param, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results) { SetManagementRoleAssignment setManagementRoleAssignment = param; if (setManagementRoleAssignment == null) { setManagementRoleAssignment = new SetManagementRoleAssignment(); } if (ouRow != null || scopeRow != null) { if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.ServerScope) { setManagementRoleAssignment.RecipientWriteScope = null; setManagementRoleAssignment.ConfigWriteScope = scopeRow.Identity; } else { if (!Util.IsDataCenter) { if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.DatabaseScope) { setManagementRoleAssignment.ConfigWriteScope = scopeRow.Identity; } else { setManagementRoleAssignment.ConfigWriteScope = null; } } if (ouRow != null) { setManagementRoleAssignment.OrganizationalUnit = new Identity(ouRow.Id, ouRow.Name); } else if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.RecipientScope) { setManagementRoleAssignment.RecipientWriteScope = scopeRow.Identity; } } } return(setManagementRoleAssignment); }
private PowerShellResults <AdminRoleGroupRow> SetRoleAssignments(IEnumerable <Identity> unchangedRoles, ManagementRoleAssignments roleAssignmentsWebService, Identity identity, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results) { if ((ouRow != null || scopeRow != null) && unchangedRoles != null) { foreach (Identity roleIdentity in unchangedRoles) { PowerShellResults <ManagementRoleAssignment> roleAssignments = this.GetRoleAssignments(roleIdentity, identity, roleAssignmentsWebService); if (roleAssignments.Failed) { results.MergeErrors <ManagementRoleAssignment>(roleAssignments); return(results); } SetManagementRoleAssignment properties = this.SetScopeInfoInParameter(roleIdentity, null, scopeRow, ouRow, results); if (results.Failed) { return(results); } ManagementRoleAssignment[] output = roleAssignments.Output; foreach (ManagementRoleAssignment managementRoleAssignment in output) { if (managementRoleAssignment.DelegationType == RoleAssignmentDelegationType.Regular) { results.MergeErrors <ManagementRoleAssignment>(roleAssignmentsWebService.SetObject(managementRoleAssignment.Identity, properties)); if (results.Failed) { return(results); } } } } return(results); } return(results); }
private PowerShellResults <AdminRoleGroupRow> AddRoleAssignments(IEnumerable <Identity> addedRoles, ManagementRoleAssignments roleAssignmentsWebService, Identity identity, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results) { if (addedRoles != null) { foreach (Identity identity2 in addedRoles) { NewManagementRoleAssignment newManagementRoleAssignment = new NewManagementRoleAssignment(); newManagementRoleAssignment.Role = identity2; newManagementRoleAssignment.SecurityGroup = identity.RawIdentity; this.SetScopeInfoInParameter(identity2, newManagementRoleAssignment, scopeRow, ouRow, results); if (results.Failed) { return(results); } results.MergeErrors <ManagementRoleAssignment>(roleAssignmentsWebService.NewObject(newManagementRoleAssignment)); } return(results); } return(results); }