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
- ObjectItemConventionAssemblyLoader.cs
- LinqDataSourceHelper.cs
- EmbeddedMailObject.cs
- RoutedCommand.cs
- UnsafeNativeMethodsMilCoreApi.cs
- Helper.cs
- FixedSOMContainer.cs
- ServiceOperationWrapper.cs
- ImageEditor.cs
- ValidatedControlConverter.cs
- XmlSchemaAnyAttribute.cs
- PolicyException.cs
- CodeCommentStatementCollection.cs
- DBConcurrencyException.cs
- RegisteredDisposeScript.cs
- Calendar.cs
- VisualStyleRenderer.cs
- TraceLog.cs
- HttpChannelHelper.cs
- ContentDesigner.cs
- SystemIPAddressInformation.cs
- XamlSerializerUtil.cs
- TimeSpanValidator.cs
- ImpersonateTokenRef.cs
- UrlMappingsModule.cs
- RuntimeWrappedException.cs
- MustUnderstandBehavior.cs
- FontDialog.cs
- PackUriHelper.cs
- BezierSegment.cs
- GradientBrush.cs
- XmlDataSourceView.cs
- DataTableReaderListener.cs
- WindowsListViewItemStartMenu.cs
- RoleServiceManager.cs
- SortAction.cs
- List.cs
- OutputCacheProfileCollection.cs
- SqlDataSourceCommandEventArgs.cs
- DocumentGrid.cs
- DiscoveryInnerClientAdhocCD1.cs
- ContentValidator.cs
- Int64Converter.cs
- ILGenerator.cs
- DocumentViewerBaseAutomationPeer.cs
- OutOfProcStateClientManager.cs
- DesignTimeHTMLTextWriter.cs
- ConcurrentStack.cs
- TabControl.cs
- UserControlParser.cs
- TemplateApplicationHelper.cs
- GetParentChain.cs
- QilFunction.cs
- DataGridViewMethods.cs
- COM2TypeInfoProcessor.cs
- RegexGroupCollection.cs
- EventProvider.cs
- SystemIcmpV6Statistics.cs
- ConnectionAcceptor.cs
- PowerStatus.cs
- MultilineStringConverter.cs
- ExternalException.cs
- JsonSerializer.cs
- DockAndAnchorLayout.cs
- Quad.cs
- ReversePositionQuery.cs
- SolidColorBrush.cs
- XPathSelfQuery.cs
- CryptoStream.cs
- CodeTypeReferenceCollection.cs
- BinaryParser.cs
- TraceEventCache.cs
- MediaScriptCommandRoutedEventArgs.cs
- HtmlHead.cs
- CodePageEncoding.cs
- CapabilitiesRule.cs
- HtmlWindow.cs
- SecurityElement.cs
- TextChange.cs
- X509Extension.cs
- DataBindingsDialog.cs
- ResXResourceSet.cs
- ResXResourceSet.cs
- StagingAreaInputItem.cs
- Selector.cs
- DataTableNewRowEvent.cs
- MultiTrigger.cs
- CachedPathData.cs
- InplaceBitmapMetadataWriter.cs
- smtppermission.cs
- EnumValAlphaComparer.cs
- VariantWrapper.cs
- StaticFileHandler.cs
- PrimitiveOperationFormatter.cs
- WebPartEventArgs.cs
- ReadOnlyHierarchicalDataSource.cs
- FullTextBreakpoint.cs
- TreeIterator.cs
- GenericsInstances.cs
- Helpers.cs