Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Net / System / Net / Mail / SmtpNtlmAuthenticationModule.cs / 5 / 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 } } // 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; // #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 } } // 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
- DragEventArgs.cs
- ContractNamespaceAttribute.cs
- EntityTypeEmitter.cs
- SystemColors.cs
- DesignerTextViewAdapter.cs
- TextPointer.cs
- SapiGrammar.cs
- Calendar.cs
- Rotation3DKeyFrameCollection.cs
- SqlHelper.cs
- GeometryHitTestResult.cs
- SqlRecordBuffer.cs
- ReadOnlyDataSourceView.cs
- ScriptBehaviorDescriptor.cs
- SizeConverter.cs
- SerializerWriterEventHandlers.cs
- DateTimeSerializationSection.cs
- XmlDownloadManager.cs
- BufferModesCollection.cs
- SpecialNameAttribute.cs
- ValidationEventArgs.cs
- DebugHandleTracker.cs
- QuaternionConverter.cs
- CustomWebEventKey.cs
- Wildcard.cs
- WsatConfiguration.cs
- MemoryStream.cs
- RegexGroup.cs
- ThreadSafeList.cs
- TextEncodedRawTextWriter.cs
- TableColumnCollectionInternal.cs
- SweepDirectionValidation.cs
- OdbcTransaction.cs
- WebPartMenuStyle.cs
- DataGridColumnDropSeparator.cs
- FormsAuthentication.cs
- ValueUnavailableException.cs
- UserControl.cs
- StyleSheetRefUrlEditor.cs
- AmbientValueAttribute.cs
- ConsumerConnectionPointCollection.cs
- EventLogPermissionEntryCollection.cs
- DataSourceControlBuilder.cs
- EntitySqlQueryCacheEntry.cs
- HijriCalendar.cs
- ButtonBaseAdapter.cs
- RemotingClientProxy.cs
- TimersDescriptionAttribute.cs
- PlatformNotSupportedException.cs
- BaseUriHelper.cs
- ObjectSecurity.cs
- SoapAttributeOverrides.cs
- OutputCacheSettings.cs
- MultiAsyncResult.cs
- EventRouteFactory.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- AmbiguousMatchException.cs
- AssemblyInfo.cs
- DbConnectionStringCommon.cs
- ClientConfigurationSystem.cs
- TreeNodeClickEventArgs.cs
- TcpAppDomainProtocolHandler.cs
- CodeLinePragma.cs
- ClientTargetSection.cs
- DBPropSet.cs
- MultiDataTrigger.cs
- StreamResourceInfo.cs
- AppearanceEditorPart.cs
- CellRelation.cs
- ExpressionParser.cs
- SafeBitVector32.cs
- Hash.cs
- WebDescriptionAttribute.cs
- SelectedCellsCollection.cs
- AttachInfo.cs
- WebServiceClientProxyGenerator.cs
- EdmSchemaError.cs
- RIPEMD160.cs
- entityreference_tresulttype.cs
- ListenerSessionConnectionReader.cs
- RegexWriter.cs
- HttpListener.cs
- DataListItemEventArgs.cs
- ParameterDataSourceExpression.cs
- StatusCommandUI.cs
- TraceInternal.cs
- URL.cs
- PixelFormat.cs
- DispatcherProcessingDisabled.cs
- DocumentsTrace.cs
- HuffmanTree.cs
- PathNode.cs
- HandledMouseEvent.cs
- SerializableAttribute.cs
- OLEDB_Enum.cs
- MonthChangedEventArgs.cs
- ConsoleEntryPoint.cs
- InvalidOperationException.cs
- MenuScrollingVisibilityConverter.cs
- SoapElementAttribute.cs