// Token: 0x060012C1 RID: 4801 RVA: 0x0004E574 File Offset: 0x0004C774 private OrganizationId DeserializeRequestorOrganizationId(HttpRequest request, ITracer tracer) { string text = request.Headers["X-Exchange-Photos-Requestor-Organization-Id"]; if (string.IsNullOrEmpty(text)) { tracer.TraceDebug((long)this.GetHashCode(), "Cannot deserialize requestor's organization id because it was not found or is blank in request."); return(null); } byte[] bytes; try { bytes = Convert.FromBase64String(text); } catch (FormatException arg) { tracer.TraceError <string, FormatException>((long)this.GetHashCode(), "Failed to deserialize requestor's organization id from base64 string: {0}. Exception: {1}", text, arg); return(null); } OrganizationId organizationId; if (!OrganizationId.TryCreateFromBytes(bytes, PhotoRequestorHeader.SerializedOrganizationIdEncoding, out organizationId)) { tracer.TraceError <string>((long)this.GetHashCode(), "Failed to deserialize requestor's organization id from base64 string: {0}", text); return(null); } tracer.TraceDebug <OrganizationId>((long)this.GetHashCode(), "Deserialized requestor's organization id: {0}", organizationId); return(organizationId); }
public SearchWorkDefinition ParseSearch(ComplianceMessage target, SearchWorkDefinition definition) { QueryFilter queryFilter = null; string query = definition.Query; CultureInfo culture; FaultDefinition faultDefinition; ExceptionHandler.Parser.TryRun(delegate { if (string.IsNullOrEmpty(target.Culture)) { culture = CultureInfo.InvariantCulture; } else { culture = CultureInfo.GetCultureInfo(target.Culture); } Func <IRecipientResolver, IPolicyTagProvider, QueryFilter> func = null; switch (definition.Parser) { case SearchWorkDefinition.QueryParser.KQL: func = ((IRecipientResolver r, IPolicyTagProvider p) => KqlParser.ParseAndBuildQuery(query, KqlParser.ParseOption.EDiscoveryMode, culture, r, p)); break; case SearchWorkDefinition.QueryParser.AQS: func = delegate(IRecipientResolver r, IPolicyTagProvider p) { AqsParser.ParseOption parseOption = AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.AllowShortWildcards; return(AqsParser.ParseAndBuildQuery(query, parseOption, culture, r, p)); }; break; } if (func != null) { OrganizationId scopingOrganizationId = null; IPolicyTagProvider arg = null; IRecipientResolver arg2 = null; if (OrganizationId.TryCreateFromBytes(target.TenantId, Encoding.UTF8, out scopingOrganizationId)) { ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(scopingOrganizationId); adsessionSettings.IncludeInactiveMailbox = true; IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 146, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs"); arg2 = new FastLocalSearchResultsProvider.RecipientIdentityResolver(tenantOrRootOrgRecipientSession); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, adsessionSettings, 149, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs"); arg = new PolicyTagAdProvider(tenantOrTopologyConfigurationSession); } queryFilter = func(arg2, arg); } if (queryFilter != null) { definition.Query = FqlQueryBuilder.ToFqlString(queryFilter, culture); } }, TimeSpan.FromMinutes(1.0), out faultDefinition, target, null, default(CancellationToken), null, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs", 102); if (faultDefinition != null) { ExceptionHandler.FaultMessage(target, faultDefinition, true); } return(definition); }
// Token: 0x06000029 RID: 41 RVA: 0x0000350C File Offset: 0x0000170C public static void FaultMessage(ComplianceMessage message, FaultDefinition fault, bool isFatal) { if (fault != null) { if (message != null) { fault.IsFatalFailure = isFatal; if (message.ProtocolContext.FaultDefinition != null && message.ProtocolContext.FaultDefinition == fault) { return; } foreach (FaultRecord faultRecord in fault.Faults) { if (!faultRecord.Data.ContainsKey("CID")) { faultRecord.Data["CID"] = message.CorrelationId.ToString(); faultRecord.Data["MID"] = message.MessageId; faultRecord.Data["MSID"] = message.MessageSourceId; if (message.MessageTarget != null) { faultRecord.Data["TID"] = message.MessageTarget.Identifier; faultRecord.Data["TTYPE"] = message.MessageTarget.TargetType.ToString(); if (message.MessageTarget.Mailbox != Guid.Empty) { faultRecord.Data["TDB"] = message.MessageTarget.Mailbox.ToString(); faultRecord.Data["TMBX"] = message.MessageTarget.Database.ToString(); } } if (message.MessageSource != null) { faultRecord.Data["STID"] = message.MessageSource.Identifier; faultRecord.Data["STTYPE"] = message.MessageSource.TargetType.ToString(); } OrganizationId organizationId; if (message.TenantId != null && OrganizationId.TryCreateFromBytes(message.TenantId, Encoding.UTF8, out organizationId)) { faultRecord.Data["TENANT"] = organizationId.OrganizationalUnit.ToString(); faultRecord.Data["TGUID"] = organizationId.OrganizationalUnit.ObjectGuid.ToString(); } faultRecord.Data["FEX"] = fault.IsFatalFailure.ToString(); } } if (isFatal) { if (message.ProtocolContext.FaultDefinition != null) { message.ProtocolContext.FaultDefinition.Merge(fault); } else { message.ProtocolContext.FaultDefinition = fault; } } } MessageLogger.Instance.LogMessageFaulted(message, fault); } }
public override PolicyConfigProvider GetPolicyStore(string tenantId) { if (tenantId == null) { throw new ArgumentNullException("tenantId"); } OrganizationId organizationId; if (!OrganizationId.TryCreateFromBytes(Convert.FromBase64String(tenantId), Encoding.UTF8, out organizationId)) { throw new ArgumentException("Cannot create OrganizationId from such tenantId: " + tenantId); } return(this.GetPolicyStore(organizationId)); }
// Token: 0x06000037 RID: 55 RVA: 0x00002BD0 File Offset: 0x00000DD0 public override ComplianceMessage Process(ComplianceMessage input) { ComplianceMessage complianceMessage = new ComplianceMessage { CorrelationId = input.CorrelationId, TenantId = input.TenantId, MessageId = default(Guid).ToString() }; FaultDefinition faultDefinition = null; RetrievedPayload payload = new RetrievedPayload(); PayloadReference payloadReference; if (!ComplianceSerializer.TryDeserialize <PayloadReference>(PayloadReference.Description, input.Payload, out payloadReference, out faultDefinition, "Process", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\TaskDistributionFabric\\Blocks\\RetrievePayloadBlock.cs", 43)) { throw new BadStructureFormatException(string.Format("Problem in deserializing the payload reference:{0}", input.ComplianceMessageType)); } OrganizationId organizationId; if (!OrganizationId.TryCreateFromBytes(input.TenantId, Encoding.UTF8, out organizationId)) { throw new ArgumentException(string.Format("Problem in creating Organization Id from the tenant id:{0}", input.ComplianceMessageType)); } Guid jobRunId; int taskId; PayloadLevel payloadLevel; if (PayloadHelper.TryReadFromPayloadReference(payloadReference, out jobRunId, out taskId, out payloadLevel)) { switch (payloadLevel) { case PayloadLevel.Job: { int taskId2; if (!int.TryParse(payloadReference.Bookmark, out taskId2)) { taskId2 = -1; } payload = this.RetrieveJobDistributionPayload(organizationId, jobRunId, taskId2); break; } case PayloadLevel.Task: payload = this.RetrieveTaskDistributionPayload(organizationId, jobRunId, taskId); break; } } complianceMessage.Payload = payload; return(complianceMessage); }
protected override IConfigDataProvider CreateSession() { if (base.ExchangeRunspaceConfig == null) { base.ThrowTerminatingError(new ComplianceJobTaskException(Strings.UnableToDetermineExecutingUser), ErrorCategory.InvalidOperation, null); } byte[] bytes = base.ExchangeRunspaceConfig.OrganizationId.GetBytes(Encoding.UTF8); OrganizationId organizationId; if (OrganizationId.TryCreateFromBytes(bytes, Encoding.UTF8, out organizationId)) { TaskLogger.LogEnter(); } return(new ComplianceJobProvider(base.ExchangeRunspaceConfig.OrganizationId)); }
public override ComplianceItemContainer GetComplianceItemContainer(string tenantId, string scope) { if (tenantId == null) { throw new ArgumentNullException("Either this.session or tenantId should be not null"); } OrganizationId scopingOrganizationId; if (!OrganizationId.TryCreateFromBytes(Convert.FromBase64String(tenantId), Encoding.UTF8, out scopingOrganizationId)) { throw new ArgumentException("Cannot create OrganizationId from such tenantId: " + tenantId); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(scopingOrganizationId), 169, "GetComplianceItemContainer", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Compliance\\ExComplianceServiceProvider.cs"); return(new ExMailboxComplianceItemContainer(tenantOrRootOrgRecipientSession, scope)); }
protected override Task <IEnumerable <ComplianceMessage> > SendMessageAsyncInternal(IEnumerable <ComplianceMessage> messages) { return(Task.Run <IEnumerable <ComplianceMessage> >(delegate() { StatusPayload statusPayload = new StatusPayload(); foreach (ComplianceMessage complianceMessage in messages) { string tenantName = string.Empty; OrganizationId organizationId; if (OrganizationId.TryCreateFromBytes(complianceMessage.TenantId, Encoding.UTF8, out organizationId) && organizationId.OrganizationalUnit != null) { tenantName = organizationId.OrganizationalUnit.Name; using (IDisposable disposable = (IDisposable)this.GetRpsProvider(tenantName)) { byte[] value = ComplianceSerializer.Serialize <ComplianceMessage>(ComplianceMessage.Description, complianceMessage); PSCommand pscommand = new PSCommand(); pscommand.AddCommand(new Command("Send-ComplianceMessage", false)); pscommand.AddParameter("SerializedComplianceMessage", value); MethodBase method = this.rpsProviderAssembly.RpsProviderType.GetMethod("Execute", new Type[] { typeof(PSCommand), typeof(TimeSpan) }); object obj = disposable; object[] array = new object[2]; array[0] = pscommand; IEnumerable <PSObject> enumerable = (IEnumerable <PSObject>)method.Invoke(obj, array); if (enumerable != null && enumerable.Count <PSObject>() == 1 && (bool)enumerable.ToArray <PSObject>()[0].BaseObject) { statusPayload.QueuedMessages.Add(complianceMessage.MessageId); } } } } return (IEnumerable <ComplianceMessage>) new ComplianceMessage[] { new ComplianceMessage { Payload = ComplianceSerializer.Serialize <StatusPayload>(StatusPayload.Description, statusPayload) } }; })); }
// Token: 0x06000753 RID: 1875 RVA: 0x0001C8A8 File Offset: 0x0001AAA8 internal static OrganizationId GetOrganizationId(string organizationIdEncoded) { if (string.IsNullOrWhiteSpace(organizationIdEncoded)) { return(OrganizationId.ForestWideOrgId); } byte[] bytes; try { bytes = Convert.FromBase64String(organizationIdEncoded); } catch (FormatException) { throw new InvalidOrganizationException(organizationIdEncoded); } OrganizationId organizationId; OrganizationId.TryCreateFromBytes(bytes, Encoding.UTF8, out organizationId); if (organizationId == null) { throw new InvalidOrganizationException(organizationIdEncoded); } return(organizationId); }
public static object ConvertFromString(string item, Type type) { if (!string.IsNullOrEmpty(item)) { type = (type ?? item.GetType()); if (type == typeof(ExchangeObjectVersion)) { return(new ExchangeObjectVersion(long.Parse(item))); } if (typeof(Enum).IsAssignableFrom(type)) { return(Enum.Parse(type, item)); } if (type == typeof(ADObjectId)) { return(new ADObjectId(SearchHelper.ConvertFromString <byte[]>(item))); } if (type == typeof(ProxyAddressCollection)) { ProxyAddressCollection proxyAddressCollection = new ProxyAddressCollection(); foreach (string item2 in item.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { proxyAddressCollection.Add(SearchHelper.ConvertFromString <ProxyAddress>(item2)); } return(proxyAddressCollection); } if (type == typeof(OrganizationId)) { OrganizationId result; if (OrganizationId.TryCreateFromBytes(SearchHelper.ConvertFromString <byte[]>(item), Encoding.Unicode, out result)) { return(result); } } else { if (type == typeof(string)) { return(item); } if (type == typeof(ProxyAddress)) { return(ProxyAddress.Parse(item)); } if (type == typeof(SmtpAddress)) { return(new SmtpAddress(SearchHelper.ConvertFromString <byte[]>(item))); } if (type == typeof(Guid)) { return(new Guid(item)); } if (type == typeof(SmtpDomain)) { return(SmtpDomain.Parse(item)); } if (type == typeof(SecurityIdentifier)) { return(new SecurityIdentifier(item)); } if (type == typeof(byte[])) { return(Convert.FromBase64String(item)); } return(ValueConvertor.ConvertValueFromString(item, type, null)); } } return(null); }
// Token: 0x06000058 RID: 88 RVA: 0x00003368 File Offset: 0x00001568 private void Deserialize(Stream stream) { using (BinaryReader binaryReader = new BinaryReader(stream)) { this.ReadAndValidateFieldType(binaryReader, 'V', Strings.MissingVersion); this.Version = this.BinaryRead <ushort>(new Func <ushort>(binaryReader.ReadUInt16), Strings.MissingVersion); this.ReadAndValidateFieldType(binaryReader, 'A', Strings.MissingAuthenticationType); string value = this.BinaryRead <string>(new Func <string>(binaryReader.ReadString), Strings.MissingAuthenticationType); AuthenticationType authenticationType; if (!Enum.TryParse <AuthenticationType>(value, out authenticationType)) { ExTraceGlobals.UserTokenTracer.TraceError <AuthenticationType>(0L, "Invalid authentication type {0}", authenticationType); throw new UserTokenException(Strings.InvalidDelegatedPrincipal(value)); } this.AuthenticationType = authenticationType; this.ReadAndValidateFieldType(binaryReader, 'D', Strings.MissingDelegatedPrincipal); string text = this.ReadNullableString(binaryReader, Strings.MissingDelegatedPrincipal); DelegatedPrincipal delegatedPrincipal = null; if (text != null && !DelegatedPrincipal.TryParseDelegatedString(text, out delegatedPrincipal)) { ExTraceGlobals.UserTokenTracer.TraceError <string>(0L, "Invalid delegated principal {0}", text); throw new UserTokenException(Strings.InvalidDelegatedPrincipal(text)); } this.DelegatedPrincipal = delegatedPrincipal; this.ReadAndValidateFieldType(binaryReader, 'L', Strings.MissingWindowsLiveId); this.WindowsLiveId = this.ReadNullableString(binaryReader, Strings.MissingWindowsLiveId); this.ReadAndValidateFieldType(binaryReader, 'N', Strings.MissingUserName); this.UserName = this.ReadNullableString(binaryReader, Strings.MissingUserName); this.ReadAndValidateFieldType(binaryReader, 'U', Strings.MissingUserSid); string text2 = this.ReadNullableString(binaryReader, Strings.MissingUserSid); if (text2 != null) { try { this.UserSid = new SecurityIdentifier(text2); } catch (ArgumentException innerException) { ExTraceGlobals.UserTokenTracer.TraceError <string>(0L, "Invalid user sid {0}", text2); throw new UserTokenException(Strings.InvalidUserSid(text2), innerException); } } this.ReadAndValidateFieldType(binaryReader, 'P', Strings.MissingPartitionId); string text3 = this.ReadNullableString(binaryReader, Strings.MissingPartitionId); PartitionId partitionId = null; if (text3 != null && !PartitionId.TryParse(text3, out partitionId)) { ExTraceGlobals.UserTokenTracer.TraceError <string>(0L, "Invalid partition id {0}", text3); throw new UserTokenException(Strings.InvalidPartitionId(text3)); } this.PartitionId = partitionId; this.ReadAndValidateFieldType(binaryReader, 'O', Strings.MissingOrganization); string text4 = this.ReadNullableString(binaryReader, Strings.MissingOrganization); if (text4 != null) { byte[] bytes; try { bytes = Convert.FromBase64String(text4); } catch (FormatException innerException2) { ExTraceGlobals.UserTokenTracer.TraceError <string>(0L, "Invalid organization id {0}", text4); throw new UserTokenException(Strings.InvalidOrganization(text4), innerException2); } OrganizationId organization; if (!OrganizationId.TryCreateFromBytes(bytes, Encoding.UTF8, out organization)) { ExTraceGlobals.UserTokenTracer.TraceError <string>(0L, "Invalid organization id {0}", text4); throw new UserTokenException(Strings.InvalidOrganization(text4)); } this.Organization = organization; } this.ReadAndValidateFieldType(binaryReader, 'M', Strings.MissingManagedOrganization); this.ManagedOrganization = this.ReadNullableString(binaryReader, Strings.MissingManagedOrganization); this.ReadAndValidateFieldType(binaryReader, 'W', Strings.MissingAppPasswordUsed); this.AppPasswordUsed = this.BinaryRead <bool>(new Func <bool>(binaryReader.ReadBoolean), Strings.MissingAppPasswordUsed); int num = (int)(binaryReader.BaseStream.Length - binaryReader.BaseStream.Position); if (num > 0) { byte[] array = binaryReader.ReadBytes(num); array = this.Decompress(array); this.CommonAccessToken = CommonAccessToken.Deserialize(Encoding.UTF8.GetString(array)); } else { this.CommonAccessToken = null; } } }
// Token: 0x0600003D RID: 61 RVA: 0x00002FCC File Offset: 0x000011CC public override ComplianceMessage Process(ComplianceMessage input) { StatusPayload statusPayload = new StatusPayload(); if (input == null) { return(new ComplianceMessage { Payload = ComplianceSerializer.Serialize <StatusPayload>(StatusPayload.Description, statusPayload) }); } statusPayload.QueuedMessages.Add(input.MessageId); WorkPayload workPayload; FaultDefinition faultDefinition; OrganizationId orgId; if (ComplianceSerializer.TryDeserialize <WorkPayload>(WorkPayload.Description, input.Payload, out workPayload, out faultDefinition, "Process", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\TaskDistributionFabric\\Blocks\\StoreResultsBlock.cs", 47) && OrganizationId.TryCreateFromBytes(input.TenantId, Encoding.UTF8, out orgId)) { Guid correlationId = input.CorrelationId; ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(orgId); ComplianceJobStatus status = ComplianceJobStatus.StatusUnknown; switch (workPayload.WorkDefinitionType) { case WorkDefinitionType.EDiscovery: status = ComplianceJobStatus.Succeeded; break; case WorkDefinitionType.Fault: status = ComplianceJobStatus.Failed; break; } complianceJobProvider.UpdateWorkloadResults(correlationId, input.Payload, ComplianceBindingType.ExchangeBinding, status); } return(new ComplianceMessage { Payload = ComplianceSerializer.Serialize <StatusPayload>(StatusPayload.Description, statusPayload) }); }