Code:
/ DotNET / DotNET / 8.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
- UIAgentMonitor.cs
- BaseParagraph.cs
- ZipArchive.cs
- DbDeleteCommandTree.cs
- TabControlDesigner.cs
- webclient.cs
- XmlNamespaceManager.cs
- Function.cs
- ConnectionPoint.cs
- ProcessStartInfo.cs
- SharedStream.cs
- ViewBox.cs
- DataGridPagerStyle.cs
- indexingfiltermarshaler.cs
- ResourceReader.cs
- TileBrush.cs
- MultiBinding.cs
- HorizontalAlignConverter.cs
- HttpTransportSecurity.cs
- CTreeGenerator.cs
- DataListItemEventArgs.cs
- ToolStripEditorManager.cs
- UnmanagedMemoryStream.cs
- UserControlCodeDomTreeGenerator.cs
- Simplifier.cs
- DoubleStorage.cs
- SelectionRange.cs
- CertificateManager.cs
- SmtpClient.cs
- DbModificationClause.cs
- TypeSource.cs
- SchemaNotation.cs
- DataSetFieldSchema.cs
- ProxyFragment.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- AddingNewEventArgs.cs
- Win32.cs
- ValueTypeFixupInfo.cs
- UIElementAutomationPeer.cs
- PointCollectionValueSerializer.cs
- TypeConverterAttribute.cs
- DocumentSequenceHighlightLayer.cs
- SqlOuterApplyReducer.cs
- StrokeFIndices.cs
- DocumentScope.cs
- BaseDataList.cs
- ReflectionPermission.cs
- SoapEnvelopeProcessingElement.cs
- LayoutInformation.cs
- BasicExpandProvider.cs
- ZipFileInfoCollection.cs
- CatalogZoneBase.cs
- SerializationInfoEnumerator.cs
- XXXInfos.cs
- DbBuffer.cs
- ViewUtilities.cs
- BitStack.cs
- WmpBitmapDecoder.cs
- AutomationProperty.cs
- ConcatQueryOperator.cs
- XmlWrappingReader.cs
- ApplicationSecurityInfo.cs
- SchemaCollectionPreprocessor.cs
- SqlNodeTypeOperators.cs
- ClientProxyGenerator.cs
- AgileSafeNativeMemoryHandle.cs
- UnhandledExceptionEventArgs.cs
- WebSysDefaultValueAttribute.cs
- ClipboardData.cs
- PageThemeParser.cs
- ValueQuery.cs
- TextDecoration.cs
- LingerOption.cs
- TextParagraph.cs
- Typeface.cs
- BrowsableAttribute.cs
- WindowsListViewItemCheckBox.cs
- DelayedRegex.cs
- DragAssistanceManager.cs
- SqlGenerator.cs
- DocumentSchemaValidator.cs
- ContentIterators.cs
- ExpandCollapsePattern.cs
- GestureRecognizer.cs
- XmlMapping.cs
- TextHidden.cs
- DataBoundControl.cs
- mda.cs
- GenericQueueSurrogate.cs
- ImageSourceConverter.cs
- EdmFunctionAttribute.cs
- PolyQuadraticBezierSegment.cs
- BindingMAnagerBase.cs
- WebConfigurationHostFileChange.cs
- HierarchicalDataTemplate.cs
- UnsafeNativeMethods.cs
- XmlQueryContext.cs
- XamlUtilities.cs
- SpanIndex.cs
- TogglePatternIdentifiers.cs