Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / Security / AuthenticationService.cs / 1 / AuthenticationService.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Security {
using System.Web.ApplicationServices;
using System.Web.Script.Services;
using System.Web.Services;
[ScriptService]
internal sealed class AuthenticationService {
[WebMethod]
public bool Login(string userName, string password, bool createPersistentCookie) {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, true);
//
if(Membership.ValidateUser(userName, password)) {
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
return true;
}
return false;
}
[WebMethod]
public void Logout() {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, false);
FormsAuthentication.SignOut();
}
[WebMethod]
public bool IsLoggedIn() {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, false);
return HttpContext.Current.Request.IsAuthenticated;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Security {
using System.Web.ApplicationServices;
using System.Web.Script.Services;
using System.Web.Services;
[ScriptService]
internal sealed class AuthenticationService {
[WebMethod]
public bool Login(string userName, string password, bool createPersistentCookie) {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, true);
//
if(Membership.ValidateUser(userName, password)) {
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
return true;
}
return false;
}
[WebMethod]
public void Logout() {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, false);
FormsAuthentication.SignOut();
}
[WebMethod]
public bool IsLoggedIn() {
ApplicationServiceHelper.EnsureAuthenticationServiceEnabled(HttpContext.Current, false);
return HttpContext.Current.Request.IsAuthenticated;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- codemethodreferenceexpression.cs
- AsyncOperation.cs
- ProfileInfo.cs
- ConsoleKeyInfo.cs
- QilReference.cs
- GeometryGroup.cs
- TemplateComponentConnector.cs
- WorkflowView.cs
- BitmapCodecInfo.cs
- MetafileHeaderWmf.cs
- ByteBufferPool.cs
- EventKeyword.cs
- _CookieModule.cs
- LineGeometry.cs
- Rect3DValueSerializer.cs
- TableLayoutPanelCellPosition.cs
- ThicknessConverter.cs
- VarRefManager.cs
- ExpressionLink.cs
- WindowProviderWrapper.cs
- EmptyEnumerable.cs
- TraceUtils.cs
- Literal.cs
- LabelTarget.cs
- ColumnWidthChangedEvent.cs
- _TLSstream.cs
- UrlAuthFailedErrorFormatter.cs
- EpmContentSerializer.cs
- BitVector32.cs
- ViewStateModeByIdAttribute.cs
- GridViewRow.cs
- ListSortDescription.cs
- FlagPanel.cs
- RadialGradientBrush.cs
- NetWebProxyFinder.cs
- ClientBuildManager.cs
- XmlSchemaRedefine.cs
- EmptyStringExpandableObjectConverter.cs
- Permission.cs
- XsltFunctions.cs
- XmlDocument.cs
- NetCodeGroup.cs
- ProfileEventArgs.cs
- RegexMatchCollection.cs
- CfgSemanticTag.cs
- DecimalAverageAggregationOperator.cs
- TransactionScopeDesigner.cs
- EntityCommandDefinition.cs
- HttpModuleAction.cs
- RequestDescription.cs
- CoTaskMemSafeHandle.cs
- CustomAssemblyResolver.cs
- HandlerFactoryWrapper.cs
- ExceptionValidationRule.cs
- InputElement.cs
- ProfileParameter.cs
- COAUTHINFO.cs
- Transform3D.cs
- SQLGuidStorage.cs
- NumericPagerField.cs
- WSSecurityPolicy11.cs
- CorrelationScope.cs
- PathFigureCollectionConverter.cs
- MultipleViewPattern.cs
- ListSortDescription.cs
- MessageQueueInstaller.cs
- HostedNamedPipeTransportManager.cs
- SequenceDesigner.cs
- URL.cs
- ValidationPropertyAttribute.cs
- Bidi.cs
- QilPatternFactory.cs
- ByteFacetDescriptionElement.cs
- NativeMethodsOther.cs
- MultiSelector.cs
- TemplateLookupAction.cs
- PeerCollaborationPermission.cs
- DataGridViewLinkColumn.cs
- HttpSessionStateWrapper.cs
- BufferModeSettings.cs
- BamlLocalizationDictionary.cs
- NamedPermissionSet.cs
- SQLGuidStorage.cs
- MethodAccessException.cs
- LocalizableAttribute.cs
- ModelUIElement3D.cs
- unitconverter.cs
- SignatureHelper.cs
- HttpCacheParams.cs
- EventLogEntry.cs
- Int64Storage.cs
- LocalIdKeyIdentifierClause.cs
- wgx_commands.cs
- Decimal.cs
- ListComponentEditor.cs
- Version.cs
- ResponseStream.cs
- Padding.cs
- TextSimpleMarkerProperties.cs
- TypeReference.cs