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
- QuotedStringWriteStateInfo.cs
- PseudoWebRequest.cs
- RepeaterDataBoundAdapter.cs
- VScrollProperties.cs
- DeviceContext2.cs
- TextFormatter.cs
- DocumentPageView.cs
- Library.cs
- MultilineStringEditor.cs
- PolyQuadraticBezierSegment.cs
- AssociativeAggregationOperator.cs
- ParserStreamGeometryContext.cs
- TcpClientSocketManager.cs
- ActivityExecutionContext.cs
- BooleanKeyFrameCollection.cs
- VisualStyleElement.cs
- Tokenizer.cs
- XDRSchema.cs
- ImageMap.cs
- MarshalDirectiveException.cs
- AppDomainAttributes.cs
- Ref.cs
- MsmqMessageProperty.cs
- DataGridViewLayoutData.cs
- FileDialogCustomPlaces.cs
- StateChangeEvent.cs
- TriggerActionCollection.cs
- MarkedHighlightComponent.cs
- COM2EnumConverter.cs
- QuadraticBezierSegment.cs
- ThicknessConverter.cs
- RawStylusInputReport.cs
- TreeBuilderXamlTranslator.cs
- BindingSource.cs
- UrlAuthFailedErrorFormatter.cs
- ViewGenResults.cs
- XmlSerializer.cs
- ConnectionProviderAttribute.cs
- HttpCachePolicy.cs
- MarshalByRefObject.cs
- RelationshipNavigation.cs
- MouseDevice.cs
- DetailsViewUpdatedEventArgs.cs
- ReflectTypeDescriptionProvider.cs
- SecurityTokenProvider.cs
- ToolStripStatusLabel.cs
- TableColumn.cs
- GenericIdentity.cs
- DataGridRow.cs
- ItemsControlAutomationPeer.cs
- Dynamic.cs
- InvokeProviderWrapper.cs
- XsdValidatingReader.cs
- XmlBoundElement.cs
- ScriptBehaviorDescriptor.cs
- MetadataItem.cs
- ExpressionWriter.cs
- WebPartMinimizeVerb.cs
- PageCatalogPart.cs
- PersistStreamTypeWrapper.cs
- Rule.cs
- KnownBoxes.cs
- TextUtf8RawTextWriter.cs
- OleAutBinder.cs
- QilFunction.cs
- QuaternionValueSerializer.cs
- ValidatingReaderNodeData.cs
- FontStretchConverter.cs
- SQLMembershipProvider.cs
- SchemaMapping.cs
- OletxCommittableTransaction.cs
- TableLayoutPanel.cs
- JournalEntryStack.cs
- XmlUtilWriter.cs
- _HelperAsyncResults.cs
- UntypedNullExpression.cs
- CssStyleCollection.cs
- NonSerializedAttribute.cs
- SourceSwitch.cs
- SqlDataSourceView.cs
- InternalConfigSettingsFactory.cs
- TrackBarRenderer.cs
- IndexerNameAttribute.cs
- TextBox.cs
- HtmlGenericControl.cs
- HScrollBar.cs
- XmlNamespaceManager.cs
- SimpleNameService.cs
- ListBindableAttribute.cs
- SafeNativeMethods.cs
- Header.cs
- _ScatterGatherBuffers.cs
- IMembershipProvider.cs
- TypeToken.cs
- ObjectStateFormatter.cs
- ValidationPropertyAttribute.cs
- CatalogPartChrome.cs
- CloudCollection.cs
- BasicViewGenerator.cs
- TreeViewImageKeyConverter.cs