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
- BigInt.cs
- SparseMemoryStream.cs
- SourceFilter.cs
- ListInitExpression.cs
- DesignerVerbToolStripMenuItem.cs
- DrawingVisual.cs
- RepeatInfo.cs
- UnsafeNativeMethods.cs
- ReturnType.cs
- LayoutInformation.cs
- PreviewPrintController.cs
- Win32Exception.cs
- ListControlConvertEventArgs.cs
- BaseParagraph.cs
- TreeViewBindingsEditorForm.cs
- Utilities.cs
- ButtonBase.cs
- NonSerializedAttribute.cs
- RecognizerInfo.cs
- DirectoryObjectSecurity.cs
- ListViewSortEventArgs.cs
- CellIdBoolean.cs
- ColumnWidthChangingEvent.cs
- DataGridViewCellValidatingEventArgs.cs
- AsnEncodedData.cs
- ClientScriptManager.cs
- HttpRequestWrapper.cs
- ReadOnlyNameValueCollection.cs
- WpfPayload.cs
- VisualStyleInformation.cs
- AddInSegmentDirectoryNotFoundException.cs
- COM2ExtendedTypeConverter.cs
- WebPartZone.cs
- IsolatedStorageFilePermission.cs
- Help.cs
- CacheSection.cs
- NullReferenceException.cs
- BinHexDecoder.cs
- CodeExporter.cs
- StructuredTypeInfo.cs
- MultitargetUtil.cs
- FacetEnabledSchemaElement.cs
- EntitySqlQueryBuilder.cs
- SqlDependency.cs
- MenuItemAutomationPeer.cs
- WebBrowserPermission.cs
- SqlUserDefinedAggregateAttribute.cs
- LinkLabel.cs
- MaterializeFromAtom.cs
- CompilationRelaxations.cs
- RedistVersionInfo.cs
- ProjectionQueryOptionExpression.cs
- TableLayoutCellPaintEventArgs.cs
- DoubleAverageAggregationOperator.cs
- Error.cs
- RichTextBox.cs
- CollectionViewGroupRoot.cs
- PageAsyncTaskManager.cs
- SystemNetworkInterface.cs
- BooleanKeyFrameCollection.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- FlowDocumentReader.cs
- DesignTimeTemplateParser.cs
- EventLogPermissionEntry.cs
- COM2ICategorizePropertiesHandler.cs
- DataGridViewColumnHeaderCell.cs
- PropertyNames.cs
- MailDefinition.cs
- FixedNode.cs
- XmlTextWriter.cs
- FtpRequestCacheValidator.cs
- DataServiceOperationContext.cs
- SqlDataSourceCommandParser.cs
- Animatable.cs
- XmlAttributeCache.cs
- BackStopAuthenticationModule.cs
- httpstaticobjectscollection.cs
- ServiceTimeoutsElement.cs
- DataGridViewDataConnection.cs
- NameValueCollection.cs
- DrawingBrush.cs
- OleDbDataAdapter.cs
- RuntimeConfigLKG.cs
- ChameleonKey.cs
- MemberProjectionIndex.cs
- Binding.cs
- Int16Converter.cs
- PageAdapter.cs
- InternalReceiveMessage.cs
- PersonalizationProviderHelper.cs
- SudsCommon.cs
- BaseDataListComponentEditor.cs
- TextShapeableCharacters.cs
- NativeMethods.cs
- SplitterPanel.cs
- PersistenceTypeAttribute.cs
- UnmanagedHandle.cs
- followingquery.cs
- TextServicesManager.cs
- ImageCodecInfo.cs