Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Mail / SmtpNtlmAuthenticationModule.cs / 2 / SmtpNtlmAuthenticationModule.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Mail { using System; using System.Collections; using System.IO; using System.Net; using System.Security.Permissions; // #if MAKE_MAILCLIENT_PUBLIC internal #else internal #endif class SmtpNtlmAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpNtlmAuthenticationModule() { } #region ISmtpAuthenticationModule Members // Security this method will access NetworkCredential properties that demand UnmanagedCode and Environment Permission [EnvironmentPermission(SecurityAction.Assert, Unrestricted=true)] [SecurityPermission(SecurityAction.Assert, Flags=SecurityPermissionFlag.UnmanagedCode)] public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie) { if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null); try { lock (this.sessions) { NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication; if (clientContext == null) { if(credential == null){ return null; } this.sessions[sessionCookie] = clientContext = new NTAuthentication(false,"Ntlm",credential,null,ContextFlags.Connection); } string resp = (challenge != null ? clientContext.GetOutgoingBlob(challenge) : clientContext.GetOutgoingBlob(null)); if (!clientContext.IsCompleted) { return new Authorization(resp, false); } else { this.sessions.Remove(sessionCookie); return new Authorization(resp, true); } } } finally { if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null); } } public string AuthenticationType { get { return "ntlm"; } } public void CloseContext(object sessionCookie) { // This is a no-op since the context is not // kept open by this module beyond auth completion. } #endregion } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WorkflowMarkupSerializationManager.cs
- Action.cs
- XmlTextAttribute.cs
- EntityDataSourceColumn.cs
- PlainXmlWriter.cs
- XmlSchemaElement.cs
- DataContractSerializerOperationBehavior.cs
- ValidateNames.cs
- Int32AnimationUsingKeyFrames.cs
- RegexCompiler.cs
- WindowsRegion.cs
- WebBrowserSiteBase.cs
- ProgressBarBrushConverter.cs
- TcpChannelHelper.cs
- DataControlField.cs
- NamespaceMapping.cs
- XslAstAnalyzer.cs
- ApplicationContext.cs
- GroupBox.cs
- Propagator.ExtentPlaceholderCreator.cs
- RuleSetReference.cs
- FixedPageProcessor.cs
- DoubleAnimationBase.cs
- WebRequestModuleElementCollection.cs
- CompoundFileReference.cs
- DebugViewWriter.cs
- IODescriptionAttribute.cs
- SafeNativeMethods.cs
- BCLDebug.cs
- BitmapSource.cs
- GPRECT.cs
- ReceiveReply.cs
- XsdDateTime.cs
- WinFormsComponentEditor.cs
- PersonalizationEntry.cs
- ItemsControlAutomationPeer.cs
- XmlSchemaInferenceException.cs
- DataGridViewBindingCompleteEventArgs.cs
- IMembershipProvider.cs
- HttpPostProtocolImporter.cs
- SelectionWordBreaker.cs
- bindurihelper.cs
- AttachedAnnotationChangedEventArgs.cs
- DataBoundLiteralControl.cs
- HotSpotCollection.cs
- EmptyStringExpandableObjectConverter.cs
- PageAsyncTaskManager.cs
- StreamGeometry.cs
- GuidConverter.cs
- CustomLineCap.cs
- MessageDecoder.cs
- BitmapSource.cs
- BitmapVisualManager.cs
- NullToBooleanConverter.cs
- FieldBuilder.cs
- EventWaitHandleSecurity.cs
- FormParameter.cs
- Polyline.cs
- DataGridViewCellStyle.cs
- SecurityPolicySection.cs
- SpoolingTaskBase.cs
- HTTPNotFoundHandler.cs
- ConfigXmlWhitespace.cs
- MatrixAnimationUsingPath.cs
- SerializationEventsCache.cs
- EditingMode.cs
- Propagator.JoinPropagator.cs
- OdbcException.cs
- GroupPartitionExpr.cs
- HttpRequestCacheValidator.cs
- DbMetaDataColumnNames.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- SatelliteContractVersionAttribute.cs
- PageBuildProvider.cs
- CharStorage.cs
- TextElementEditingBehaviorAttribute.cs
- ButtonRenderer.cs
- RoutedEventArgs.cs
- SQlBooleanStorage.cs
- SettingsSavedEventArgs.cs
- ParserContext.cs
- ICollection.cs
- WebPartCatalogCloseVerb.cs
- HttpConfigurationSystem.cs
- Mapping.cs
- QuaternionValueSerializer.cs
- XPathBuilder.cs
- DataGridItemCollection.cs
- RoleGroupCollection.cs
- _SecureChannel.cs
- CqlWriter.cs
- ManagementScope.cs
- StylusOverProperty.cs
- HashStream.cs
- DesignerMetadata.cs
- PropertyGridView.cs
- MimeBasePart.cs
- PopupRoot.cs
- HtmlElementCollection.cs
- DesignerDataTable.cs