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
- ResizeGrip.cs
- MultiSelectRootGridEntry.cs
- InputMethodStateChangeEventArgs.cs
- SecurityElement.cs
- updatecommandorderer.cs
- DbConnectionPoolCounters.cs
- EventListener.cs
- MetricEntry.cs
- XPathSelectionIterator.cs
- StickyNote.cs
- Int64AnimationBase.cs
- AstNode.cs
- AttributeQuery.cs
- PropertyChangeTracker.cs
- SqlRemoveConstantOrderBy.cs
- TcpClientCredentialType.cs
- PageParser.cs
- DataGridViewColumnTypeEditor.cs
- TableLayoutStyle.cs
- COM2ExtendedTypeConverter.cs
- RuleSettings.cs
- CalendarDayButton.cs
- ProfessionalColors.cs
- WebConfigurationFileMap.cs
- NetStream.cs
- HttpWebRequest.cs
- PackWebRequestFactory.cs
- EventLogEntryCollection.cs
- DoubleSumAggregationOperator.cs
- Underline.cs
- SqlCommand.cs
- SyntaxCheck.cs
- SemanticTag.cs
- LinkArea.cs
- DataGridItem.cs
- ClaimComparer.cs
- CodeMemberMethod.cs
- ListControlActionList.cs
- DBDataPermission.cs
- SrgsOneOf.cs
- BrowserDefinitionCollection.cs
- DiagnosticsConfiguration.cs
- WebControlAdapter.cs
- GeneralTransform.cs
- SecurityHeaderElementInferenceEngine.cs
- NeutralResourcesLanguageAttribute.cs
- SymLanguageVendor.cs
- SharedDp.cs
- PointCollection.cs
- TransformValueSerializer.cs
- DataGridViewTextBoxEditingControl.cs
- InvalidComObjectException.cs
- NamespaceList.cs
- StateDesigner.Helpers.cs
- UnitySerializationHolder.cs
- IndexingContentUnit.cs
- UrlPropertyAttribute.cs
- UseAttributeSetsAction.cs
- AdornedElementPlaceholder.cs
- BaseValidatorDesigner.cs
- UndoManager.cs
- XmlILOptimizerVisitor.cs
- Util.cs
- ModelVisual3D.cs
- EntityDataSource.cs
- WebPartMenu.cs
- DeploymentSectionCache.cs
- FileLogRecordEnumerator.cs
- DataAdapter.cs
- RequestUriProcessor.cs
- MD5Cng.cs
- BookmarkScopeManager.cs
- UnsafeNativeMethods.cs
- CheckedPointers.cs
- FontDifferentiator.cs
- Page.cs
- XamlStyleSerializer.cs
- DoubleStorage.cs
- UniqueConstraint.cs
- WizardForm.cs
- PropertyCondition.cs
- Menu.cs
- ApplicationException.cs
- XmlNamedNodeMap.cs
- PeerNameResolver.cs
- EventMappingSettings.cs
- HwndAppCommandInputProvider.cs
- StringUtil.cs
- ClientTargetSection.cs
- ScanQueryOperator.cs
- ParentUndoUnit.cs
- ChannelCacheSettings.cs
- UnicastIPAddressInformationCollection.cs
- HttpGetProtocolImporter.cs
- HealthMonitoringSection.cs
- DayRenderEvent.cs
- ProfileBuildProvider.cs
- ReadOnlyDataSource.cs
- DataGridViewMethods.cs
- DataProtection.cs