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
- XmlDataDocument.cs
- MeasureData.cs
- ResolveMatchesMessageCD1.cs
- GroupItemAutomationPeer.cs
- TextBox.cs
- GlobalItem.cs
- TextTreeFixupNode.cs
- PropertyPushdownHelper.cs
- ImageSource.cs
- FixedBufferAttribute.cs
- CheckBox.cs
- CompilationUnit.cs
- AuthenticationConfig.cs
- ResourceManager.cs
- externdll.cs
- SqlMultiplexer.cs
- PackagePartCollection.cs
- ConvertersCollection.cs
- QueueProcessor.cs
- XamlFrame.cs
- WebPartConnection.cs
- SecureConversationServiceCredential.cs
- EmptyControlCollection.cs
- HttpsChannelListener.cs
- DBParameter.cs
- HGlobalSafeHandle.cs
- IQueryable.cs
- SmiEventSink.cs
- TreeNodeCollectionEditor.cs
- ChoiceConverter.cs
- DataTableReader.cs
- HotSpotCollection.cs
- BamlRecordHelper.cs
- ConfigurationManagerHelper.cs
- ValuePatternIdentifiers.cs
- ObjectTag.cs
- UnconditionalPolicy.cs
- HttpCachePolicyBase.cs
- MembershipAdapter.cs
- SoapIgnoreAttribute.cs
- BevelBitmapEffect.cs
- ToolStripContextMenu.cs
- SHA512.cs
- DataServiceStreamResponse.cs
- SqlMethods.cs
- AllMembershipCondition.cs
- PanelStyle.cs
- GridViewDeletedEventArgs.cs
- DataGridViewCellLinkedList.cs
- Pen.cs
- EndpointBehaviorElementCollection.cs
- DebugView.cs
- QilStrConcat.cs
- AssemblyName.cs
- DbModificationCommandTree.cs
- AsymmetricAlgorithm.cs
- MultipleViewPattern.cs
- WindowsListViewGroupSubsetLink.cs
- BufferAllocator.cs
- AdornerLayer.cs
- SeekStoryboard.cs
- ExtendedPropertiesHandler.cs
- CommonDialog.cs
- SystemColorTracker.cs
- XmlIgnoreAttribute.cs
- TextFindEngine.cs
- CodeTypeReferenceExpression.cs
- SqlServices.cs
- ReaderWriterLockWrapper.cs
- DrawingGroupDrawingContext.cs
- TypeReference.cs
- shaperfactoryquerycacheentry.cs
- TrackingRecord.cs
- StaticTextPointer.cs
- ProtocolViolationException.cs
- DataGridViewColumnDesigner.cs
- DbConnectionPool.cs
- DictionaryMarkupSerializer.cs
- XpsResourcePolicy.cs
- NativeWrapper.cs
- SingleAnimationBase.cs
- FunctionNode.cs
- ParagraphResult.cs
- CustomErrorCollection.cs
- FunctionDefinition.cs
- XmlAttributeOverrides.cs
- CaseInsensitiveHashCodeProvider.cs
- CaseStatementSlot.cs
- CharStorage.cs
- JobStaple.cs
- StandardOleMarshalObject.cs
- LabelEditEvent.cs
- StringUtil.cs
- sqlmetadatafactory.cs
- PropertyInformation.cs
- Typography.cs
- CodeComment.cs
- TypeForwardedToAttribute.cs
- NavigationWindow.cs
- XmlSerializerObjectSerializer.cs