protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } UMMailbox ummailbox = UMMailbox.FromDataObject(aduser); if (ummailbox.UMDialPlan != null) { UMDialPlan dialPlan = ummailbox.GetDialPlan(); if (dialPlan != null && (dialPlan.URIType == UMUriType.E164 || dialPlan.URIType == UMUriType.SipName)) { ummailbox.SIPResourceIdentifier = UMMailbox.GetPrimaryExtension(ummailbox.EmailAddresses, ProxyAddressPrefix.UM); } if (dialPlan != null) { ummailbox.PhoneNumber = ummailbox.GetEUMPhoneNumber(dialPlan); } ummailbox.AccessTelephoneNumbers = dialPlan.AccessTelephoneNumbers; ummailbox.CallAnsweringRulesExtensions = new MultiValuedProperty <string>(Utils.GetExtensionsInDialPlanValidForPAA(dialPlan, aduser)); } return(ummailbox); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.IsInherited) { return; } if (this.Owner != null) { this.owner = SecurityPrincipalIdParameter.GetUserSid(base.TenantGlobalCatalogSession, this.Owner, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (base.ParameterSetName == "Instance" || base.ParameterSetName == "AccessRights") { if (!base.ToGrantFullAccess() && this.AutoMapping != null && this.AutoMapping.Value) { base.WriteError(new InvalidOperationException(Strings.ErrorSpecifyAutoMappingOnNonFullAccess), ErrorCategory.InvalidOperation, null); } if (base.Instance.AccessRights != null && base.Instance.AccessRights.Length != 0) { if (Array.Exists <MailboxRights>(base.Instance.AccessRights, (MailboxRights right) => (right & MailboxRights.SendAs) == MailboxRights.SendAs)) { base.WriteError(new InvalidOperationException(Strings.ErrorSetSendAsOnMailboxPermissionNotAllowed), ErrorCategory.InvalidOperation, null); } } } TaskLogger.LogExit(); }
private ADObjectId ValidateUser(SecurityPrincipalIdParameter principalId) { if (principalId == null) { return(null); } IEnumerable <ADRecipient> objects = principalId.GetObjects <ADRecipient>(null, base.TenantGlobalCatalogSession); ADObjectId result; using (IEnumerator <ADRecipient> enumerator = objects.GetEnumerator()) { if (!enumerator.MoveNext()) { base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorUserNotFound(principalId.ToString())), ErrorCategory.ObjectNotFound, null); } ADObjectId adobjectId = (ADObjectId)enumerator.Current.Identity; if (enumerator.MoveNext()) { base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorUserNotUnique(principalId.ToString())), ErrorCategory.InvalidData, null); } this.WriteWarning(Strings.AccountPrivilegeWarning); result = adobjectId; } return(result); }
protected override void InternalBeginProcessing() { base.InternalBeginProcessing(); if (this.Trustee != null) { this.trusteeSid = SecurityPrincipalIdParameter.GetUserSid(base.TenantGlobalCatalogSession, this.Trustee, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); base.InternalBeginProcessing(); if (this.User != null) { this.securityPrincipal = SecurityPrincipalIdParameter.GetSecurityPrincipal(base.TenantGlobalCatalogSession, this.User, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } TaskLogger.LogExit(); }
private SecurityPrincipalIdParameter[] GetChangedValues(bool added) { if (this.Members == null) { return(new SecurityPrincipalIdParameter[0]); } object[] array = added ? this.Members.Added : this.Members.Removed; SecurityPrincipalIdParameter[] array2 = new SecurityPrincipalIdParameter[array.Length]; array.CopyTo(array2, 0); return(array2); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } return(new LinkedUser(aduser)); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser user = (ADUser)dataObject; SharedConfiguration sharedConfig = null; if (SharedConfiguration.IsDehydratedConfiguration(user.OrganizationId) || (SharedConfiguration.GetSharedConfigurationState(user.OrganizationId) & SharedTenantConfigurationState.Static) != SharedTenantConfigurationState.UnSupported) { sharedConfig = base.ProvisioningCache.TryAddAndGetOrganizationData <SharedConfiguration>(CannedProvisioningCacheKeys.MailboxSharedConfigCacheKey, user.OrganizationId, () => SharedConfiguration.GetSharedConfiguration(user.OrganizationId)); } if (null != user.MasterAccountSid) { user.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(user.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); user.ResetChangeTracking(); } Mailbox mailbox = new Mailbox(user); mailbox.propertyBag.SetField(MailboxSchema.Database, ADObjectIdResolutionHelper.ResolveDN(mailbox.Database)); if (sharedConfig != null) { mailbox.SharedConfiguration = sharedConfig.SharedConfigId.ConfigurationUnit; if (mailbox.RoleAssignmentPolicy == null) { mailbox.RoleAssignmentPolicy = base.ProvisioningCache.TryAddAndGetOrganizationData <ADObjectId>(CannedProvisioningCacheKeys.MailboxRoleAssignmentPolicyCacheKey, user.OrganizationId, () => sharedConfig.GetSharedRoleAssignmentPolicy()); } } else if (mailbox.RoleAssignmentPolicy == null && !mailbox.ExchangeVersion.IsOlderThan(MailboxSchema.RoleAssignmentPolicy.VersionAdded)) { ADObjectId defaultRoleAssignmentPolicy = RBACHelper.GetDefaultRoleAssignmentPolicy(user.OrganizationId); if (defaultRoleAssignmentPolicy != null) { mailbox.RoleAssignmentPolicy = defaultRoleAssignmentPolicy; } } if (mailbox.SharingPolicy == null && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.SharingPolicy)) { mailbox.SharingPolicy = base.GetDefaultSharingPolicyId(user, sharedConfig); } if (mailbox.RetentionPolicy == null && mailbox.ShouldUseDefaultRetentionPolicy && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetentionPolicy)) { mailbox.RetentionPolicy = base.GetDefaultRetentionPolicyId(user, sharedConfig); } if (mailbox.Database != null && mailbox.UseDatabaseRetentionDefaults) { this.SetDefaultRetentionValues(mailbox); } mailbox.AdminDisplayVersion = Microsoft.Exchange.Data.Directory.SystemConfiguration.Server.GetServerVersion(mailbox.ServerName); return(mailbox); }
protected override void InternalBeginProcessing() { if (Constants.IsPowerShellWebService && base.ExchangeRunspaceConfig != null && base.ExchangeRunspaceConfig.ConfigurationSettings.EncodeDecodeKey && base.DynamicParametersInstance.IsModified(AcePresentationObjectSchema.User)) { SecurityPrincipalIdParameter securityPrincipalIdParameter = base.DynamicParametersInstance[AcePresentationObjectSchema.User] as SecurityPrincipalIdParameter; IIdentityParameter identityParameter; if (securityPrincipalIdParameter != null && PswsPropertyConverterModule.TryDecodeIIdentityParameter(securityPrincipalIdParameter, out identityParameter)) { base.DynamicParametersInstance[AcePresentationObjectSchema.User] = (identityParameter as SecurityPrincipalIdParameter); } } base.InternalBeginProcessing(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); this.trustee = (ADRecipient)SecurityPrincipalIdParameter.GetSecurityPrincipal((IRecipientSession)base.DataSession, this.Trustee, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); List <ActiveDirectoryAccessRule> list = new List <ActiveDirectoryAccessRule>(); foreach (RecipientAccessRight right in this.AccessRights) { list.Add(new ActiveDirectoryAccessRule(((IADSecurityPrincipal)this.trustee).Sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, RecipientPermissionHelper.GetRecipientAccessRightGuid(right), this.GetInheritanceType(), Guid.Empty)); } this.ApplyModification(list.ToArray()); TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.IsInherited) { return; } if (this.Owner != null) { this.owner = SecurityPrincipalIdParameter.GetUserSid(base.GlobalCatalogRecipientSession, this.Owner, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } TaskLogger.LogExit(); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { ADGroup adgroup = (ADGroup)dataObject; if (null != adgroup.ForeignGroupSid) { adgroup.LinkedGroup = SecurityPrincipalIdParameter.GetFriendlyUserName(adgroup.ForeignGroupSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); adgroup.ResetChangeTracking(); } RoleGroup roleGroup = RoleGroupCommon.PopulateRoleAssignmentsAndConvert(adgroup, this.ConfigurationSession); roleGroup.PopulateCapabilitiesProperty(); return(roleGroup); }
protected override void WriteResult(ADObject result) { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); ADUser aduser = (ADUser)result; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } base.WriteResult(new LinkedUser(aduser)); TaskLogger.LogExit(); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } MailboxPlan mailboxPlan = new MailboxPlan(aduser); mailboxPlan.Database = ADObjectIdResolutionHelper.ResolveDN(mailboxPlan.Database); return(mailboxPlan); }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); base.InternalBeginProcessing(); this.readOnlyRecipientSession = PermissionTaskHelper.GetReadOnlyRecipientSession(this.DomainController); if (this.readOnlyRecipientSession.UseGlobalCatalog) { this.globalCatalogRecipientSession = this.readOnlyRecipientSession; } else { this.globalCatalogRecipientSession = PermissionTaskHelper.GetReadOnlyRecipientSession(null); } if (this.User != null) { this.securityPrincipal = SecurityPrincipalIdParameter.GetUserSid(this.GlobalCatalogRecipientSession, this.User, new Task.TaskErrorLoggingDelegate(base.ThrowTerminatingError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } TaskLogger.LogExit(); }
internal static string GetFriendlyNameOfSecurityIdentifier(SecurityIdentifier sid, IRecipientSession session, Task.TaskErrorLoggingDelegate errorLogger, Task.TaskVerboseLoggingDelegate verboseLogger) { if (!RecipientPermissionTaskHelper.sidToName.ContainsKey(sid)) { ADRecipient adrecipient = (ADRecipient)SecurityPrincipalIdParameter.GetSecurityPrincipal(session, new SecurityPrincipalIdParameter(sid), errorLogger, verboseLogger); if (adrecipient != null) { if (adrecipient.Id != null) { RecipientPermissionTaskHelper.sidToName[sid] = adrecipient.Id.ToString(); } else { RecipientPermissionTaskHelper.sidToName[sid] = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, verboseLogger); } } } return(RecipientPermissionTaskHelper.sidToName[sid]); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } CASMailbox casmailbox = CASMailbox.FromDataObject(aduser); if ((this.GetPopProtocolLog || this.GetImapProtocolLog || this.ActiveSyncDebugLogging) && CmdletProxy.TryToProxyOutputObject(casmailbox, base.CurrentTaskContext, aduser, this.Identity == null, this.ConfirmationMessage, CmdletProxy.AppendIdentityToProxyCmdlet(aduser))) { return(casmailbox); } if (casmailbox.ActiveSyncMailboxPolicy == null && !casmailbox.ExchangeVersion.IsOlderThan(CASMailboxSchema.ActiveSyncMailboxPolicy.VersionAdded)) { ADObjectId defaultPolicyId = base.GetDefaultPolicyId(aduser); if (defaultPolicyId != null) { casmailbox.SetActiveSyncMailboxPolicyLocally(defaultPolicyId); casmailbox.ActiveSyncMailboxPolicyIsDefaulted = true; } } if (this.GetPopProtocolLog || this.GetImapProtocolLog) { this.GetProtocolLogs(aduser); } if (this.ProtocolSettings) { this.PopulateProtocolSettings(casmailbox); } if (this.ActiveSyncDebugLogging) { casmailbox.ActiveSyncDebugLogging = this.GetActiveSyncLoggingEnabled(aduser); } return(casmailbox); }
private string GetDisplayNameFromSid(string userSid) { if (this.resolvedUserNameList.ContainsKey(userSid)) { return(this.resolvedUserNameList[userSid]); } SecurityIdentifier securityIdentifier = new SecurityIdentifier(userSid); ADRecipient adrecipient = this.recipientSessionInternal.FindBySid(securityIdentifier); string text; if (adrecipient != null) { text = MailboxAuditLogSearchWorker.ResolveMailboxOwnerName(adrecipient); } else { text = SecurityPrincipalIdParameter.GetFriendlyUserName(securityIdentifier, null); } this.resolvedUserNameList[userSid] = text; return(text); }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(this.DataObject.Identity, base.DataSession, typeof(RoleGroup))); ADGroup adgroup = null; try { adgroup = (ADGroup)base.DataSession.Read <ADGroup>(this.DataObject.Identity); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (adgroup == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(this.DataObject.Identity), typeof(RoleGroup).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, this.DataObject.Identity); } Result <ExchangeRoleAssignment>[] array = null; if (this.roleAssignments != null) { array = new Result <ExchangeRoleAssignment> [this.roleAssignments.Count]; for (int i = 0; i < this.roleAssignments.Count; i++) { array[i] = new Result <ExchangeRoleAssignment>(this.roleAssignments[i], null); } } if (null != adgroup.ForeignGroupSid) { adgroup.LinkedGroup = SecurityPrincipalIdParameter.GetFriendlyUserName(adgroup.ForeignGroupSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); adgroup.ResetChangeTracking(); } RoleGroup result = new RoleGroup(adgroup, array); base.WriteResult(result); TaskLogger.LogExit(); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); this.DataObject = (ExchangeRoleAssignment)base.PrepareDataObject(); if (base.HasErrors) { return(null); } ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.User, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorUserOrSecurityGroupNotFound(this.User.ToString())), new LocalizedString?(Strings.ErrorUserOrSecurityGroupNotUnique(this.User.ToString()))); RoleHelper.ValidateRoleAssignmentUser(adrecipient, new Task.TaskErrorLoggingDelegate(base.WriteError), false); this.originalUserId = this.DataObject.User; this.DataObject.User = adrecipient.Id; this.DataObject.RoleAssigneeType = ExchangeRoleAssignment.RoleAssigneeTypeFromADRecipient(adrecipient); ((IDirectorySession)base.DataSession).LinkResolutionServer = adrecipient.OriginatingServer; if (!adrecipient.OrganizationId.Equals(OrganizationId.ForestWideOrgId) && !adrecipient.OrganizationId.Equals(this.DataObject.OrganizationId) && (OrganizationId.ForestWideOrgId.Equals(this.DataObject.OrganizationId) || !this.DataObject.OrganizationId.OrganizationalUnit.IsDescendantOf(adrecipient.OrganizationId.OrganizationalUnit))) { base.WriteError(new InvalidOperationException(Strings.ErrorOrgUserBeAssignedToParentOrg(this.User.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Id); } TaskLogger.LogExit(); return(this.DataObject); }
public List <SecurityIdentifier> ConvertGuidsToSid(string[] rawGuids) { List <Guid> list = new List <Guid>(); foreach (string input in rawGuids) { Guid guid; if (!Guid.TryParse(input, out guid)) { throw new FaultException(string.Format("Guid {0} is invalid", guid)); } list.Add(guid); } if (list != null && list.Any <Guid>()) { IRecipientSession session = (IRecipientSession)this.CreateAdSession(); List <SecurityIdentifier> list2 = new List <SecurityIdentifier>(); foreach (Guid guid2 in list) { SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(guid2.ToString()); IEnumerable <ADRecipient> objects = securityPrincipalIdParameter.GetObjects <ADRecipient>(null, session); using (IEnumerator <ADRecipient> enumerator2 = objects.GetEnumerator()) { if (enumerator2.MoveNext()) { ADRecipient adrecipient = enumerator2.Current; list2.Add(adrecipient.MasterAccountSid ?? ((IADSecurityPrincipal)adrecipient).Sid); if (enumerator2.MoveNext()) { throw new Exception(Strings.ErrorUserNotUnique(guid2.ToString())); } } } } return(list2); } return(new List <SecurityIdentifier>()); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (!base.CurrentTaskContext.CanBypassRBACScope) { base.VerifyIsWithinScopes((IRecipientSession)base.DataSession, this.DataObject, true, new DataAccessTask <ADUser> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); } if (this.IsInherited) { this.WriteWarning(Strings.ErrorWillNotPerformOnInheritedAccessRight(this.Instance.Identity.ToString())); return; } if (base.ParameterSetName == "Owner") { return; } if (this.Instance.User != null) { this.securityPrincipal = SecurityPrincipalIdParameter.GetSecurityPrincipal(base.TenantGlobalCatalogSession, this.Instance.User, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (this.IsInherited) { return; } if (base.ParameterSetName == "Instance") { if (this.Instance.User == null) { base.WriteError(new ArgumentException(Strings.ErrorUserNull, "User"), ErrorCategory.InvalidArgument, null); } if (this.Instance.AccessRights == null || this.Instance.AccessRights.Length == 0) { base.WriteError(new ArgumentException(Strings.ErrorAccessRightsEmpty, "AccessRights"), ErrorCategory.InvalidArgument, null); } } TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (this.IsInherited) { TPublicObject instance = this.Instance; this.WriteWarning(Strings.ErrorWillNotPerformOnInheritedAccessRight(instance.Identity.ToString())); return; } if (base.ParameterSetName == "Owner") { return; } TPublicObject instance2 = this.Instance; if (instance2.User != null) { IRecipientSession session = this.GlobalCatalogRecipientSession; TPublicObject instance3 = this.Instance; this.securityPrincipal = SecurityPrincipalIdParameter.GetSecurityPrincipal(session, instance3.User, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (base.IsInherited) { return; } if ("Owner" == base.ParameterSetName) { ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadMailboxSecurityDescriptor(this.DataObject, PermissionTaskHelper.GetReadOnlySession(base.DomainController), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); SecurityIdentifier sid = this.owner; activeDirectorySecurity.SetOwner(sid); new RawSecurityDescriptor(activeDirectorySecurity.GetSecurityDescriptorBinaryForm(), 0); PermissionTaskHelper.SaveMailboxSecurityDescriptor(this.DataObject, activeDirectorySecurity, base.DataSession, ref this.storeSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); string friendlyUserName = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); base.WriteObject(new OwnerPresentationObject(this.DataObject.Id, friendlyUserName)); } else { base.InternalProcessRecord(); } TaskLogger.LogExit(); }
internal static string GetCreatedByUserDisplayName(string rawName) { string result = string.Empty; if (!string.IsNullOrEmpty(rawName)) { result = rawName; int num = rawName.IndexOf("\\"); if (num > -1 && num < rawName.Length - 1) { result = rawName.Substring(num + 1); } else { try { SecurityIdentifier sid = new SecurityIdentifier(rawName); SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(sid); IEnumerable <SecurityPrincipalIdParameter> sidPrincipalId = new SecurityPrincipalIdParameter[] { securityPrincipalIdParameter }.AsEnumerable <SecurityPrincipalIdParameter>(); List <AcePermissionRecipientRow> list = RecipientObjectResolver.Instance.ResolveSecurityPrincipalId(sidPrincipalId).ToList <AcePermissionRecipientRow>(); if (list.Count > 0) { result = list[0].DisplayName; } } catch (ArgumentException ex) { DDIHelper.Trace("Created by value is not a valid SID: " + ex.Message); } } } return(result); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (base.IsInherited) { return; } if ("Owner" == base.ParameterSetName) { IConfigurationSession writableSession = base.GetWritableSession(this.DataObject.Id); ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadAdSecurityDescriptor(this.DataObject, writableSession, new Task.TaskErrorLoggingDelegate(base.WriteError)); SecurityIdentifier sid = this.owner; activeDirectorySecurity.SetOwner(sid); RawSecurityDescriptor sd = new RawSecurityDescriptor(activeDirectorySecurity.GetSecurityDescriptorBinaryForm(), 0); writableSession.SaveSecurityDescriptor(this.DataObject.Id, sd, true); string friendlyUserName = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); base.WriteObject(new OwnerPresentationObject(this.DataObject.Id, friendlyUserName)); } else { base.InternalProcessRecord(); } TaskLogger.LogExit(); }
internal ADRecipient GetRecipient(SecurityPrincipalIdParameter securityPrincipalIdParameter, Task.ErrorLoggerDelegate writeError) { return((ADRecipient)base.GetDataObject <ADRecipient>(securityPrincipalIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(securityPrincipalIdParameter.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(securityPrincipalIdParameter.ToString())))); }
protected static object GetSingleProperty(object prop, Type type) { if (prop == null) { return(null); } object obj = null; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]); } else if (type == typeof(ADObjectId) && prop is PSObject) { obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString())); } else if (type == typeof(EnhancedTimeSpan)) { obj = EnhancedTimeSpan.Parse(prop.ToString()); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString()); } else if (type == typeof(ByteQuantifiedSize)) { obj = ByteQuantifiedSize.Parse(prop.ToString()); } else if (type == typeof(Unlimited <ByteQuantifiedSize>)) { obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString()); } else if (type == typeof(Unlimited <int>)) { obj = Unlimited <int> .Parse(prop.ToString()); } else if (type == typeof(ProxyAddress)) { obj = ProxyAddress.Parse(prop.ToString()); } else if (type == typeof(SmtpAddress)) { obj = new SmtpAddress(prop.ToString()); } else if (type == typeof(SmtpDomain)) { obj = SmtpDomain.Parse(prop.ToString()); } else if (type == typeof(CountryInfo)) { obj = CountryInfo.Parse(prop.ToString()); } else if (type == typeof(SharingPolicyDomain)) { obj = SharingPolicyDomain.Parse(prop.ToString()); } else if (type == typeof(ApprovedApplication)) { obj = ApprovedApplication.Parse(prop.ToString()); } else if (type == typeof(SmtpDomainWithSubdomains)) { obj = SmtpDomainWithSubdomains.Parse(prop.ToString()); } else if (type == typeof(UMLanguage)) { obj = UMLanguage.Parse(prop.ToString()); } else if (type == typeof(UMSmartHost)) { obj = UMSmartHost.Parse(prop.ToString()); } else if (type == typeof(ScheduleInterval)) { obj = ScheduleInterval.Parse(prop.ToString()); } else if (type == typeof(NumberFormat)) { obj = NumberFormat.Parse(prop.ToString()); } else if (type == typeof(DialGroupEntry)) { obj = DialGroupEntry.Parse(prop.ToString()); } else if (type == typeof(CustomMenuKeyMapping)) { obj = CustomMenuKeyMapping.Parse(prop.ToString()); } else if (type == typeof(HolidaySchedule)) { obj = HolidaySchedule.Parse(prop.ToString()); } else if (type == typeof(UMTimeZone)) { obj = UMTimeZone.Parse(prop.ToString()); } else if (type == typeof(ServerVersion)) { obj = ServerVersion.ParseFromSerialNumber(prop.ToString()); } else if (type == typeof(X509Certificate2)) { obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]); } else if (type == typeof(LocalizedString)) { obj = new LocalizedString(prop.ToString()); } else if (type == typeof(ExchangeObjectVersion)) { obj = ExchangeObjectVersion.Parse(prop.ToString()); } else if (type == typeof(bool)) { obj = bool.Parse(prop.ToString()); } else if (type == typeof(SecurityPrincipalIdParameter)) { obj = new SecurityPrincipalIdParameter(prop.ToString()); } else if (type == typeof(ActiveDirectoryAccessRule)) { obj = (prop as ActiveDirectoryAccessRule); } else if (type == typeof(ObjectId)) { string text = prop.ToString(); if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/")) { text = MockObjectCreator.ConvertDNFromTreeStructure(text); } obj = new ADObjectId(text); } else if (type.IsEnum) { try { obj = Enum.Parse(type, prop.ToString()); } catch (ArgumentException) { obj = Enum.GetValues(type).GetValue(0); } } return(obj ?? prop); }
public object Convert(object sourceObject) { switch (this.resolverType) { case ResolverType.Recipient: if (sourceObject is IEnumerable <ADObjectId> ) { sourceObject = RecipientObjectResolver.Instance.ResolveObjects(sourceObject as IEnumerable <ADObjectId>).ToList <RecipientObjectResolverRow>(); } else if (sourceObject is ADObjectId) { sourceObject = RecipientObjectResolver.Instance.ResolveObjects(new ADObjectId[] { sourceObject as ADObjectId }).First <RecipientObjectResolverRow>(); } break; case ResolverType.OrganizationUnitIdentity: if (sourceObject is IEnumerable <ADObjectId> ) { sourceObject = RecipientObjectResolver.Instance.ResolveOrganizationUnitIdentity(sourceObject as IEnumerable <ADObjectId>).ToList <Identity>(); } else if (sourceObject is ADObjectId) { sourceObject = RecipientObjectResolver.Instance.ResolveOrganizationUnitIdentity(new ADObjectId[] { sourceObject as ADObjectId }).First <Identity>(); } break; case ResolverType.SidToRecipient: if (sourceObject is IEnumerable <SecurityPrincipalIdParameter> ) { sourceObject = RecipientObjectResolver.Instance.ResolveSecurityPrincipalId(sourceObject as IEnumerable <SecurityPrincipalIdParameter>).ToList <AcePermissionRecipientRow>(); } else if (sourceObject is SecurityPrincipalIdParameter) { IEnumerable <SecurityPrincipalIdParameter> sidPrincipalId = new SecurityPrincipalIdParameter[] { sourceObject as SecurityPrincipalIdParameter }.AsEnumerable <SecurityPrincipalIdParameter>(); sourceObject = RecipientObjectResolver.Instance.ResolveSecurityPrincipalId(sidPrincipalId).First <AcePermissionRecipientRow>(); } break; case ResolverType.RetentionPolicyTag: if (sourceObject is IEnumerable <ADObjectId> ) { sourceObject = RetentionPolicyTagObjectResolver.Instance.ResolveObjects(sourceObject as IEnumerable <ADObjectId>).ToList <RetentionPolicyTagResolverRow>(); } else if (sourceObject is ADObjectId) { sourceObject = RetentionPolicyTagObjectResolver.Instance.ResolveObjects(new ADObjectId[] { sourceObject as ADObjectId }).First <RetentionPolicyTagResolverRow>(); } break; case ResolverType.Server: if (sourceObject is IEnumerable <ADObjectId> ) { sourceObject = ServerResolver.Instance.ResolveObjects(sourceObject as IEnumerable <ADObjectId>).ToList <ServerResolverRow>(); } else if (sourceObject is ADObjectId) { sourceObject = ServerResolver.Instance.ResolveObjects(new ADObjectId[] { sourceObject as ADObjectId }).First <ServerResolverRow>(); } break; } return(sourceObject); }
private void CompleteDataObject(ExtendedSecurityPrincipal dataObject) { dataObject.UserFriendlyName = SecurityPrincipalIdParameter.GetFriendlyUserName(dataObject.SID, null); }