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
- HierarchicalDataTemplate.cs
- ConsoleKeyInfo.cs
- StringArrayConverter.cs
- ProjectionPathSegment.cs
- SqlParameter.cs
- GC.cs
- List.cs
- FieldTemplateUserControl.cs
- ZipIOLocalFileHeader.cs
- TreeNodeClickEventArgs.cs
- CodeEntryPointMethod.cs
- PeerNameRecord.cs
- IndicShape.cs
- TextSelectionProcessor.cs
- WebPartEventArgs.cs
- CodeDefaultValueExpression.cs
- SecurityResources.cs
- TrackingServices.cs
- UxThemeWrapper.cs
- CoreSwitches.cs
- ToolStripPanel.cs
- XmlEncodedRawTextWriter.cs
- GeometryHitTestParameters.cs
- HttpHandlerActionCollection.cs
- ExpressionSelection.cs
- XPathAxisIterator.cs
- ControlBindingsCollection.cs
- PerformanceCounterManager.cs
- CodeFieldReferenceExpression.cs
- SqlCommandBuilder.cs
- StrongNameUtility.cs
- LogRecordSequence.cs
- WindowVisualStateTracker.cs
- JapaneseCalendar.cs
- MappingMetadataHelper.cs
- Matrix3DValueSerializer.cs
- HostSecurityManager.cs
- AuthenticationService.cs
- XmlDataDocument.cs
- StrongNameMembershipCondition.cs
- TriState.cs
- BasicAsyncResult.cs
- TypeToArgumentTypeConverter.cs
- MonitorWrapper.cs
- InternalPolicyElement.cs
- DataControlFieldCollection.cs
- ListViewPagedDataSource.cs
- GregorianCalendar.cs
- HandlerBase.cs
- Window.cs
- HtmlHead.cs
- ServiceNameElement.cs
- SectionInput.cs
- NumericUpDown.cs
- EventLogPermissionEntry.cs
- PropertyFilterAttribute.cs
- ProfilePropertySettingsCollection.cs
- XsdSchemaFileEditor.cs
- ThreadInterruptedException.cs
- XmlC14NWriter.cs
- SignedXml.cs
- InternalConfigEventArgs.cs
- ListView.cs
- TemplateInstanceAttribute.cs
- QilInvokeEarlyBound.cs
- MarshalDirectiveException.cs
- IsolatedStorage.cs
- ListDesigner.cs
- UnitySerializationHolder.cs
- DiscoveryServiceExtension.cs
- TemplateBindingExpression.cs
- InkCanvasAutomationPeer.cs
- Section.cs
- _ContextAwareResult.cs
- ChangeConflicts.cs
- Rotation3DKeyFrameCollection.cs
- CommandPlan.cs
- ResourcePart.cs
- ContentIterators.cs
- DataFieldCollectionEditor.cs
- HelloOperation11AsyncResult.cs
- TransformedBitmap.cs
- InheritanceContextChangedEventManager.cs
- TypeLoadException.cs
- OleAutBinder.cs
- ServiceModelInstallComponent.cs
- PreparingEnlistment.cs
- VisualStyleElement.cs
- ResourceDescriptionAttribute.cs
- UrlAuthorizationModule.cs
- GetChildSubtree.cs
- BackStopAuthenticationModule.cs
- Event.cs
- HostedHttpRequestAsyncResult.cs
- RijndaelManaged.cs
- RegisteredHiddenField.cs
- NavigationProperty.cs
- PrintPreviewGraphics.cs
- UnmanagedMemoryStream.cs
- UIPermission.cs