public static LicenseIdentity GetLicenseIdentity(RmsClientManagerContext context, string recipientAddress) { ArgumentValidator.ThrowIfNull("context", context); ArgumentValidator.ThrowIfNullOrEmpty("recipientAddress", recipientAddress); ADRawEntry adrawEntry; try { adrawEntry = context.ResolveRecipient(recipientAddress); } catch (ADTransientException innerException) { throw new ExchangeConfigurationException(ServerStrings.FailedToReadUserConfig(recipientAddress), innerException); } catch (ADOperationException innerException2) { throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(recipientAddress), innerException2); } if (adrawEntry == null) { throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(recipientAddress)); } List <string> federatedEmailAddresses = RmsClientManagerUtils.GetFederatedEmailAddresses(context.OrgId, (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]); if (federatedEmailAddresses.Count == 0) { RmsClientManager.TraceFail(null, context.SystemProbeId, "GetLicenseIdentity: User {0} doesn't have any SMTP proxy address from a domain that is federated.", new object[] { recipientAddress }); throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFederated, DirectoryStrings.UserHasNoSmtpProxyAddressWithFederatedDomain); } return(new LicenseIdentity(federatedEmailAddresses[0], federatedEmailAddresses.ToArray())); }
public static LicenseeIdentity[] ConvertToLicenseeIdentities(RmsClientManagerContext context, string[] identities) { ArgumentValidator.ThrowIfNull("context", context); RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("identities", identities); LicenseeIdentity[] array = new LicenseeIdentity[identities.Length]; for (int i = 0; i < identities.Length; i++) { if (!SmtpAddress.IsValidSmtpAddress(identities[i])) { throw new RightsManagementException(RightsManagementFailureCode.InvalidRecipient, ServerStrings.RecipientAddressInvalid(identities[i])); } ADRawEntry adrawEntry; try { adrawEntry = context.ResolveRecipient(identities[i]); } catch (ADTransientException innerException) { throw new ExchangeConfigurationException(ServerStrings.FailedToReadUserConfig(identities[i]), innerException); } catch (ADOperationException innerException2) { throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(identities[i]), innerException2); } IList <string> list = RmsClientManagerUtils.EmptyProxyList; string text = null; bool flag = false; if (adrawEntry != null) { ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]; if (proxyAddressCollection != null && proxyAddressCollection.Count != 0) { list = new List <string>(proxyAddressCollection.Count); foreach (ProxyAddress proxyAddress in proxyAddressCollection) { list.Add(proxyAddress.ValueString); } } SmtpAddress smtpAddress = (SmtpAddress)adrawEntry[ADRecipientSchema.PrimarySmtpAddress]; if (smtpAddress.IsValidAddress) { text = smtpAddress.ToString(); } flag = RmsClientManagerUtils.TreatRecipientAsRMSSuperuser(context.OrgId, (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails]); } array[i] = new LicenseeIdentity(string.IsNullOrEmpty(text) ? identities[i] : text, list, flag); } return(array); }