Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / RoleProviderPrincipal.cs / 2 / RoleProviderPrincipal.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Security
{
using System;
using System.Runtime.CompilerServices;
using System.ServiceModel;
using System.Security.Principal;
using System.ServiceModel.Security;
using System.Web.Security;
sealed class RoleProviderPrincipal : IPrincipal
{
static bool defaultRoleProviderSet = false;
static object defaultRoleProvider;
object roleProvider;
ServiceSecurityContext securityContext;
public RoleProviderPrincipal(object roleProvider, ServiceSecurityContext securityContext)
{
this.roleProvider = roleProvider;
this.securityContext = securityContext;
}
public IIdentity Identity
{
get { return this.securityContext.PrimaryIdentity; }
}
[MethodImpl(MethodImplOptions.NoInlining)]
public bool IsInRole(string role)
{
object roleProvider = this.roleProvider ?? GetRoleProvider();
RoleProvider rp = roleProvider as RoleProvider;
if ( rp != null)
{
return rp.IsUserInRole(this.securityContext.PrimaryIdentity.Name, role);
}
return false;
}
// This method used to be static and had this comment, made instance as part of AH fix [[....]] 8/2008
// Perf benefit: Roles.Enabled call is expensive due to CAS.
[MethodImpl(MethodImplOptions.NoInlining)]
object GetRoleProvider()
{
if (!defaultRoleProviderSet)
{
defaultRoleProvider = Roles.Enabled ? Roles.Provider : null;
defaultRoleProviderSet = true;
}
return defaultRoleProvider;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- __Filters.cs
- XhtmlTextWriter.cs
- StateMachine.cs
- PointF.cs
- ObjectPropertyMapping.cs
- InOutArgument.cs
- CounterSet.cs
- XmlDomTextWriter.cs
- OleDbEnumerator.cs
- MemoryStream.cs
- WSIdentityFaultException.cs
- ElementFactory.cs
- Rotation3DAnimationUsingKeyFrames.cs
- BindingOperations.cs
- ContextMenuService.cs
- SvcFileManager.cs
- ArraySubsetEnumerator.cs
- SystemResourceKey.cs
- SinglePageViewer.cs
- DataBindingExpressionBuilder.cs
- SynchronizationContext.cs
- ColorConverter.cs
- cryptoapiTransform.cs
- InternalMappingException.cs
- KeyFrames.cs
- LambdaCompiler.Address.cs
- WindowsClaimSet.cs
- SocketElement.cs
- VectorAnimation.cs
- OleDbWrapper.cs
- ImageMetadata.cs
- UnicastIPAddressInformationCollection.cs
- MulticastNotSupportedException.cs
- XmlTextEncoder.cs
- IncrementalReadDecoders.cs
- DebugView.cs
- DecoratedNameAttribute.cs
- XmlSigningNodeWriter.cs
- HttpListenerPrefixCollection.cs
- DoubleAnimationUsingKeyFrames.cs
- SQLRoleProvider.cs
- ItemCheckedEvent.cs
- SQLMoney.cs
- ProviderBase.cs
- SoapIncludeAttribute.cs
- DataTemplateKey.cs
- MemoryMappedViewStream.cs
- UriWriter.cs
- WriteableBitmap.cs
- ConfigXmlReader.cs
- ImageDrawing.cs
- DBSchemaRow.cs
- SplineQuaternionKeyFrame.cs
- HeaderUtility.cs
- TextElement.cs
- Matrix3D.cs
- LocalBuilder.cs
- BuildResultCache.cs
- X509ServiceCertificateAuthenticationElement.cs
- Page.cs
- TypedOperationInfo.cs
- SizeIndependentAnimationStorage.cs
- ValidatorCompatibilityHelper.cs
- Matrix.cs
- Util.cs
- DateTimeValueSerializer.cs
- SqlDataReaderSmi.cs
- WebPartTracker.cs
- StackBuilderSink.cs
- DragEvent.cs
- Msec.cs
- DataGridViewTextBoxCell.cs
- MatcherBuilder.cs
- UpdatePanelTrigger.cs
- DeploymentExceptionMapper.cs
- HtmlEmptyTagControlBuilder.cs
- XmlSchemaSubstitutionGroup.cs
- SelectionListComponentEditor.cs
- ToolboxComponentsCreatedEventArgs.cs
- RemoteWebConfigurationHostStream.cs
- Vector3DCollectionConverter.cs
- DocumentViewerHelper.cs
- EntityDataSourceSelectingEventArgs.cs
- ObjectQuery.cs
- HotCommands.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- EmptyWorkItem.cs
- MulticastNotSupportedException.cs
- StaticExtensionConverter.cs
- OrderedDictionary.cs
- WebServiceClientProxyGenerator.cs
- PartitionResolver.cs
- SendActivityValidator.cs
- Win32Native.cs
- PropertyItem.cs
- ServicePointManagerElement.cs
- Group.cs
- Enumerable.cs
- FeatureSupport.cs
- TreeNodeSelectionProcessor.cs