December 16, 2009

Impersonator.cs

#region Namespaces
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
#endregion

namespace WF
{
public class Impersonator : IDisposable
{
#region Declarations
private WindowsImpersonationContext _impersonatedUser = null;
private IntPtr _userHandle;
#endregion

#region Impersonator
public Impersonator()
{
_userHandle = new IntPtr(0);
string user = ConfigurationSettings.AppSettings["StrAdmin"].ToString();
string userDomain = ConfigurationSettings.AppSettings["StrDomain"].ToString();
string password = ConfigurationSettings.AppSettings["StrAdminPswd"].ToString();

bool returnValue = LogonUser(user, userDomain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref _userHandle);
if (!returnValue)
throw new ApplicationException("Could not impersonate user");
WindowsIdentity newId = new WindowsIdentity(_userHandle);
_impersonatedUser = newId.Impersonate();
}
#endregion

#region IDisposable Members

public void Dispose()
{
if (_impersonatedUser != null)
{
_impersonatedUser.Undo();
CloseHandle(_userHandle);
}
}

#endregion

#region Interop imports/constants
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_LOGON_SERVICE = 3;
public const int LOGON32_PROVIDER_DEFAULT = 0;

[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern bool LogonUser(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
#endregion
}
}

December 08, 2009

stsadm is not recognized as an internal or external command, operable program or batch file.

Add stsadm.exe to paths, in other words, make Windows able to execute stsadm no matter what folder you are in.

Click Start > Control panel > System > Advanced system setings

Under “System Variables” click Path (You will need to scroll down a bit). Click edit. At the end of the line add:

;C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BIN

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...