Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / SystemIdentity.cs / 1 / SystemIdentity.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.ComponentModel; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Principal; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; internal sealed class SystemIdentity : IDisposable { bool m_isDisposed; WindowsIdentity m_identity; object m_sync; public static readonly IdentityReference LsaIdentityReference = new SecurityIdentifier( "SY" ); public SystemIdentity( bool throwIfAlreadySystem ) { m_sync = new object(); WindowsIdentity identity = WindowsIdentity.GetCurrent(); if( identity.IsSystem && throwIfAlreadySystem ) { // // This is an internal fatal error. // throw IDT.ThrowHelperError( new InvalidOperationException( SR.GetString( SR.UserIdentityEqualSystemNotSupported ) ) ); } else if( !identity.IsSystem ) { m_identity = identity; #pragma warning suppress 56523 if( !NativeMethods.RevertToSelf() ) { IDT.Assert( false, "Identity management failure" ); } } else { // // Do nothing. we are LSA already and throwIfAlreadySystem == false // IDT.Assert( null == m_identity, "m_identity should be null when we are system and throwIfAlreadySystem == false" ); } } void IDisposable.Dispose() { if ( m_isDisposed ) { return; } lock( m_sync ) { if( m_isDisposed ) { return; } m_isDisposed = true; if( null != m_identity ) { // // Impersonate the user // if( !NativeMethods.ImpersonateLoggedOnUser( m_identity.Token ) ) { int hr = Marshal.GetHRForLastWin32Error(); // // This exception is fatal to our service. // it could corrupt the flow of identity that the service expects. // Failfast here. // Diagnostics.InfoCardTrace.FailFast( String.Format( CultureInfo.InvariantCulture, SR.GetString( SR.StoreImpersonateLoggedOnUserFailed ), hr ) ); } m_identity.Dispose(); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RectAnimation.cs
- ColumnHeader.cs
- BaseCodeDomTreeGenerator.cs
- DiscoveryClientChannelFactory.cs
- EntityDataSourceWrapper.cs
- ListViewEditEventArgs.cs
- WindowsTitleBar.cs
- WebPartAuthorizationEventArgs.cs
- PersistNameAttribute.cs
- BuildManagerHost.cs
- ImageDrawing.cs
- StringUtil.cs
- TemplatedWizardStep.cs
- SourceFileBuildProvider.cs
- PlainXmlWriter.cs
- EllipticalNodeOperations.cs
- InkCollectionBehavior.cs
- ViewStateException.cs
- HtmlInputImage.cs
- JsonGlobals.cs
- AssociatedControlConverter.cs
- PropertyEmitterBase.cs
- DrawToolTipEventArgs.cs
- ChangeBlockUndoRecord.cs
- StreamInfo.cs
- Wizard.cs
- ReferenceEqualityComparer.cs
- ResourcesGenerator.cs
- CodeConstructor.cs
- Sentence.cs
- Queue.cs
- SqlParameterCollection.cs
- DiscoveryClient.cs
- StorageBasedPackageProperties.cs
- ActivatedMessageQueue.cs
- Content.cs
- ServicePoint.cs
- DoubleCollectionValueSerializer.cs
- XNodeValidator.cs
- EncoderParameters.cs
- SiteMapHierarchicalDataSourceView.cs
- FunctionDetailsReader.cs
- ClientSettingsProvider.cs
- TextContainerHelper.cs
- SqlConnectionHelper.cs
- XmlExpressionDumper.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- SettingsPropertyWrongTypeException.cs
- ValidateNames.cs
- Update.cs
- SessionEndingCancelEventArgs.cs
- ContentControl.cs
- BitmapDecoder.cs
- LongValidatorAttribute.cs
- ImageList.cs
- ModuleBuilder.cs
- CatalogZone.cs
- CompiledQuery.cs
- XmlILConstructAnalyzer.cs
- InternalException.cs
- FileUtil.cs
- RSACryptoServiceProvider.cs
- MetadataException.cs
- NetNamedPipeBindingElement.cs
- ColumnBinding.cs
- HybridDictionary.cs
- DataSourceXmlAttributeAttribute.cs
- SmiGettersStream.cs
- OutputCacheProfile.cs
- FastEncoderWindow.cs
- Wizard.cs
- Button.cs
- FilterFactory.cs
- Timer.cs
- EntityDataSourceSelectedEventArgs.cs
- AlphaSortedEnumConverter.cs
- ToolZone.cs
- CacheOutputQuery.cs
- RayMeshGeometry3DHitTestResult.cs
- StaticSiteMapProvider.cs
- CommunicationObjectManager.cs
- SoapExtensionReflector.cs
- LinkLabel.cs
- ButtonFieldBase.cs
- _SslSessionsCache.cs
- DeferrableContent.cs
- SynchronizationFilter.cs
- SByteStorage.cs
- _OSSOCK.cs
- EntityDataSourceDesignerHelper.cs
- RoleGroup.cs
- QueryLifecycle.cs
- WrappingXamlSchemaContext.cs
- _NestedMultipleAsyncResult.cs
- TextureBrush.cs
- TimeoutException.cs
- NetworkInformationException.cs
- ProfileParameter.cs
- DataSourceXmlSerializationAttribute.cs
- EntitySqlQueryState.cs