private void SetWindowsPrincipal()
        {
            WindowsIdentity windowsIdentity = null;

            try
            {
                //using (WindowsIdentity.Impersonate(IntPtr.Zero))
                //{
                //	windowsIdentity = XmlaClient.SPProxy.GetWindowsIdentityFromCurrentPrincipal();
                //}
            }
            catch
            {
            }
            if (windowsIdentity == null || !windowsIdentity.User.Equals(WindowsIdentity.GetCurrent().User))
            {
                XmlaClient.TraceVerbose("Setting windows principal on the thread to match the windows user {0}", new object[]
                {
                    WindowsIdentity.GetCurrent().Name
                });
                this.originalPrincipal  = Thread.CurrentPrincipal;
                Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                return;
            }
            XmlaClient.TraceVerbose("SharePoint principal matches windows user so leaving SharePoint principal. User {0}", new object[]
            {
                WindowsIdentity.GetCurrent().Name
            });
        }
        private void SetWindowsIdentity()
        {
            XmlaClient.TraceVerbose("Recovering windows identity from SharePoint", new object[0]);
            WindowsIdentity windowsIdentityFromCurrentPrincipal = XmlaClient.SPProxy.GetWindowsIdentityFromCurrentPrincipal();

            this.originalPrincipal = Thread.CurrentPrincipal;
            //this.ctx = windowsIdentityFromCurrentPrincipal.Impersonate();
            Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            XmlaClient.TraceVerbose("Set thread identity to user '{0}'", new object[]
            {
                windowsIdentityFromCurrentPrincipal.Name
            });
        }