Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / SmtpNtlmAuthenticationModule.cs / 1305376 / 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; using System.Security.Authentication.ExtendedProtection; // #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, string spn, ChannelBinding channelBindingToken) { 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, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); 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 } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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; using System.Security.Authentication.ExtendedProtection; // #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, string spn, ChannelBinding channelBindingToken) { 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, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); 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 } } // 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
- TableStyle.cs
- ImageListImage.cs
- MatrixAnimationUsingKeyFrames.cs
- TrackingValidationObjectDictionary.cs
- UnicodeEncoding.cs
- InlineUIContainer.cs
- UidManager.cs
- SqlCacheDependencySection.cs
- MessageUtil.cs
- FilterEventArgs.cs
- Selection.cs
- RenderData.cs
- AccessibleObject.cs
- PersonalizableTypeEntry.cs
- LineGeometry.cs
- GZipStream.cs
- Span.cs
- ReliableOutputSessionChannel.cs
- ParameterModifier.cs
- ClickablePoint.cs
- controlskin.cs
- DataRelation.cs
- FrameworkContentElementAutomationPeer.cs
- SoapProtocolReflector.cs
- GPPOINTF.cs
- CancelEventArgs.cs
- PreservationFileWriter.cs
- CacheOutputQuery.cs
- XmlReader.cs
- CacheChildrenQuery.cs
- DataServiceRequestException.cs
- recordstate.cs
- InvalidComObjectException.cs
- TableCellCollection.cs
- SemanticResultKey.cs
- ClonableStack.cs
- UriTemplateVariablePathSegment.cs
- EnumerableRowCollectionExtensions.cs
- Point3DValueSerializer.cs
- TabControlCancelEvent.cs
- WeakHashtable.cs
- SignedInfo.cs
- PersistenceException.cs
- ReliabilityContractAttribute.cs
- cookieexception.cs
- TCEAdapterGenerator.cs
- BlobPersonalizationState.cs
- PrivilegedConfigurationManager.cs
- ComboBoxAutomationPeer.cs
- SecurityElement.cs
- RecordConverter.cs
- SafeSecurityHelper.cs
- ChangePassword.cs
- FixedTextPointer.cs
- FactoryGenerator.cs
- DesignerRegionMouseEventArgs.cs
- ScrollableControlDesigner.cs
- QuaternionRotation3D.cs
- WeakEventManager.cs
- RoutedEventConverter.cs
- BaseParaClient.cs
- WebPartConnectionsCancelEventArgs.cs
- MatcherBuilder.cs
- DesignerView.xaml.cs
- NullToBooleanConverter.cs
- AssemblyHash.cs
- NumericUpDown.cs
- _FtpDataStream.cs
- SafeEventLogWriteHandle.cs
- Validator.cs
- DiscoveryClientDocuments.cs
- XmlArrayAttribute.cs
- InputMethodStateChangeEventArgs.cs
- MimeBasePart.cs
- DataGrid.cs
- XPathArrayIterator.cs
- ReturnEventArgs.cs
- PropertyChangeTracker.cs
- InputProcessorProfiles.cs
- BaseConfigurationRecord.cs
- CodeAttributeArgumentCollection.cs
- SqlRecordBuffer.cs
- DataBoundControlParameterTarget.cs
- QuotedPairReader.cs
- Brush.cs
- SchemaCollectionPreprocessor.cs
- DynamicDiscoveryDocument.cs
- TripleDES.cs
- AppearanceEditorPart.cs
- UnauthorizedWebPart.cs
- XmlAutoDetectWriter.cs
- Exceptions.cs
- LoadedOrUnloadedOperation.cs
- SendKeys.cs
- CryptoStream.cs
- InternalTransaction.cs
- SQLGuid.cs
- Duration.cs
- BrowserDefinitionCollection.cs
- TextCompositionManager.cs