Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / RoleGroup.cs / 1 / RoleGroup.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.ComponentModel;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Security;
///
/// Associates a collection of roles with a template.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class RoleGroup {
private ITemplate _contentTemplate;
private string[] _roles;
///
/// The template associated with the roles.
///
[
Browsable(false),
DefaultValue(null),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(LoginView)),
]
public ITemplate ContentTemplate {
get {
return _contentTemplate;
}
set {
_contentTemplate = value;
}
}
///
/// The roles associated with the template.
///
[
TypeConverterAttribute(typeof(StringArrayConverter)),
]
public string[] Roles {
get {
if (_roles == null) {
return new string[0];
}
else {
// Must clone to preserve encapsulation
return (string[]) _roles.Clone();
}
}
set {
if (value == null) {
_roles = value;
}
else {
// Must clone to preserve encapsulation
_roles = (string[]) value.Clone();
}
}
}
///
/// Whether the user is in any of the roles.
///
public bool ContainsUser(IPrincipal user) {
if (user == null) {
throw new ArgumentNullException("user");
}
if (_roles == null) {
return false;
}
foreach (string role in _roles) {
if (user.IsInRole(role)) {
return true;
}
}
return false;
}
///
/// For appearance in designer collection editor.
///
public override string ToString() {
StringArrayConverter converter = new StringArrayConverter();
return converter.ConvertToString(Roles);
}
}
}
// 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
- WrappedKeySecurityTokenParameters.cs
- ImageDrawing.cs
- ExtensionMethods.cs
- Hex.cs
- CodeAccessSecurityEngine.cs
- ApplicationHost.cs
- JumpTask.cs
- MemberCollection.cs
- HeaderCollection.cs
- FileSystemEventArgs.cs
- AssociationType.cs
- UserControl.cs
- XPathExpr.cs
- DataGridViewElement.cs
- Collection.cs
- CodeSubDirectory.cs
- AmbientProperties.cs
- ConnectionProviderAttribute.cs
- ConfigurationElementProperty.cs
- ScriptingSectionGroup.cs
- CompilerTypeWithParams.cs
- ADMembershipProvider.cs
- DataSourceXmlSubItemAttribute.cs
- DisposableCollectionWrapper.cs
- CatalogPartChrome.cs
- BinaryParser.cs
- ETagAttribute.cs
- ThousandthOfEmRealPoints.cs
- DataListItem.cs
- VirtualPathProvider.cs
- ConditionalAttribute.cs
- SafeLibraryHandle.cs
- Exceptions.cs
- HtmlInputButton.cs
- DBAsyncResult.cs
- ScriptingRoleServiceSection.cs
- XamlSerializationHelper.cs
- ImageSourceValueSerializer.cs
- SafePEFileHandle.cs
- HtmlMeta.cs
- SolidColorBrush.cs
- TypeConverterAttribute.cs
- HtmlEmptyTagControlBuilder.cs
- Transform3DGroup.cs
- BinaryParser.cs
- HandleCollector.cs
- TypeDelegator.cs
- AutomationPeer.cs
- NGCUIElementCollectionSerializerAsync.cs
- SchemaElementDecl.cs
- IsolatedStorageFilePermission.cs
- X509SecurityTokenProvider.cs
- TransportConfigurationTypeElementCollection.cs
- AddressingProperty.cs
- ConstraintCollection.cs
- MultitargetUtil.cs
- BaseTransportHeaders.cs
- MethodImplAttribute.cs
- GACIdentityPermission.cs
- FixedSOMTableRow.cs
- NavigationPropertyEmitter.cs
- Size3DConverter.cs
- XXXOnTypeBuilderInstantiation.cs
- RsaSecurityKey.cs
- DomainConstraint.cs
- LoadedOrUnloadedOperation.cs
- StyleSheetRefUrlEditor.cs
- TemplateInstanceAttribute.cs
- SendMailErrorEventArgs.cs
- SelectedDatesCollection.cs
- Quaternion.cs
- XsltException.cs
- FlowDocumentReaderAutomationPeer.cs
- GenericAuthenticationEventArgs.cs
- ExpressionsCollectionConverter.cs
- GifBitmapEncoder.cs
- DropTarget.cs
- CannotUnloadAppDomainException.cs
- CodeGen.cs
- IISMapPath.cs
- SettingsAttributeDictionary.cs
- DateTimeParse.cs
- AttributeCollection.cs
- InputScope.cs
- InvokeSchedule.cs
- TextBox.cs
- OperationDescriptionCollection.cs
- HwndHost.cs
- DataServicePagingProviderWrapper.cs
- BorderGapMaskConverter.cs
- XmlQueryOutput.cs
- TdsParserSessionPool.cs
- GZipDecoder.cs
- XPathDocumentNavigator.cs
- FirstMatchCodeGroup.cs
- PasswordRecovery.cs
- CaretElement.cs
- StrongNameMembershipCondition.cs
- BookmarkScopeManager.cs
- _LoggingObject.cs