private bool GetRpsEnabledFlag(SecurityIdentifier sid, PartitionId partitionId, out string errorMsg) { int hashCode = this.GetHashCode(); ExTraceGlobals.HttpModuleTracer.TraceFunction((long)hashCode, "[RemotePowerShellAuthModule::GetRpsEnabledFlag] Enter."); bool result = true; errorMsg = null; try { ExTraceGlobals.HttpModuleTracer.TraceDebug((long)hashCode, "[RemotePowerShellAuthModule::GetRpsEnabledFlag] Find ADRawEntry by Sid."); ADRawEntry adrawEntry = UserTokenStaticHelper.GetADRawEntry(partitionId, null, sid); if (adrawEntry != null) { ExTraceGlobals.HttpModuleTracer.TraceDebug((long)hashCode, "[RemotePowerShellAuthModule::GetRpsEnabledFlag] Find a ADRawEntry."); result = (adrawEntry[ADRecipientSchema.RemotePowerShellEnabled] == null || (bool)adrawEntry[ADRecipientSchema.RemotePowerShellEnabled]); } } catch (TransientException ex) { errorMsg = ex.Message; } catch (DataSourceOperationException ex2) { errorMsg = ex2.Message; } catch (DataValidationException ex3) { errorMsg = ex3.Message; } ExTraceGlobals.HttpModuleTracer.TraceFunction((long)hashCode, "[RemotePowerShellAuthModule::GetRpsEnabledFlag] Exit."); return(result); }
// Token: 0x06000013 RID: 19 RVA: 0x00002980 File Offset: 0x00000B80 internal static bool TryResolveCurrentUserInLocalForest(IPrincipal user, TraceSource traceSrc, out string tenantName) { tenantName = null; ADRawEntry adrawEntry = null; if (user != null) { SecurityIdentifier securityIdentifier = null; PartitionId partitionId = null; GenericSidIdentity genericSidIdentity = user.Identity as GenericSidIdentity; if (genericSidIdentity != null) { securityIdentifier = genericSidIdentity.Sid; if (!string.IsNullOrEmpty(genericSidIdentity.PartitionId)) { PartitionId.TryParse(genericSidIdentity.PartitionId, out partitionId); } } else { WindowsIdentity windowsIdentity = user.Identity as WindowsIdentity; if (windowsIdentity != null) { securityIdentifier = windowsIdentity.User; } } if (securityIdentifier != null) { Logger.LogVerbose(traceSrc, "User sid is {0}.", new object[] { securityIdentifier.ToString() }); try { adrawEntry = UserTokenStaticHelper.GetADRawEntry(partitionId, null, securityIdentifier); goto IL_11E; } catch (TransientException exception) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following transient error {0}.", exception, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } catch (DataSourceOperationException exception2) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following error {0}.", exception2, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } catch (DataValidationException exception3) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following error {0}.", exception3, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } } Logger.LogWarning(traceSrc, "Identity in the context is not valid. It should be either GenericSidIdentity or WindowsIdentity."); } else { Logger.LogWarning(traceSrc, "Context.User is null."); } IL_11E: if (adrawEntry != null) { Logger.LogVerbose(traceSrc, "User SMTP address resolved from AD {0}.", new object[] { (SmtpAddress)adrawEntry[ADRecipientSchema.WindowsLiveID] }); ADObjectId adobjectId = (ADObjectId)adrawEntry[ADObjectSchema.OrganizationalUnitRoot]; if (adobjectId != null) { tenantName = adobjectId.Name; Logger.LogVerbose(traceSrc, "User Tenant Name resolved from AD {0}.", new object[] { tenantName }); } } return adrawEntry != null; }