Sunday 11 December 2016

Backup(Export) / Restore(Import) Passwords in Google Chrome

Backup/Export
  • Open Chrome://flags in your Chrome
  • Find Password Import and Export option, select Enabled from the drop-down box, and then restart the Chrome browser
  • Now, open Chrome://settings/passwords page
  • Click on Export button to export/backup saved passwords
  • Enter your Windows account password, when asked
  • Passwords will be saved into a CSV file

Restore/Import
  • Open Chrome://settings/passwords page
  • Click the Import button to restore previously saved passwords


Wednesday 9 November 2016

Friday 14 October 2016

Require PowerShell Modules to Excute CmdLets in C#

Add the following Powershell library as a reference:
C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0

Import the following libraries in C#:
  • using System.Management.Automation;
  • using System.Management.Automation.Runspaces;


Create a C# method:
public void ExecuteScript(string fileName)
{
     try
     {
         string script = File.ReadAllText(fileName);
         var shell = PowerShell.Create();
         shell.Commands.AddScript(script);
         shell.Invoke();
     }
     catch (Exception) {
         // Exception Handling Code
     }
}


Wednesday 5 October 2016

Get Network Account ID in IIS and ASP.NET

  1. Follow this link to DisableLoopbackCheck more...
  2. In IIS, set the desire application pool to: "ApplicaitonPoolIdentity"
  3. In IIS, set the "Authentication" for the desire website to only "Windows Authentication = Enabled" and others disabled
  4. In you ASP.NET application, under default page:
    • Session["UserName"] = Utilities.GetUserNetworkLoginName(Request.ServerVariables["AUTH_USER"]);
  5.  In "Utilities" class, use the following method to get the user in both IIS Express and IIS:
    •  public static string GetUserNetworkLoginName(string networkLoginId)
              {           
                  if (string.IsNullOrEmpty(networkLoginId))
                      networkLoginId = WindowsIdentity.GetCurrent().Name;

                  // if login contains monet\, drop it
                  if (networkLoginId.Contains("\\"))
                      networkLoginId = networkLoginId.Substring(networkLoginId.LastIndexOf("\\") + 1);

                  return networkLoginId;
              }


Thursday 18 August 2016

  • Assigning File Share permissions using Power Shell more...
  • Managing File Shares with Windows PowerShell more...
 

Monday 8 August 2016

​Hiding a Mailbox from the Global Address List with Directory Syncronization Enabled


Hiding and/or un-hiding a mailbox from the Global Address List (GAL) when Directory Syncronization is enabled, is a bit tricky. To know how to hide/un-hide mailbox from GAL, follow this article more...


Saturday 23 July 2016

C# Active Directory Get Account Status

public static bool GetAccountStatus(string alias, string property)
{
    UserPrincipal user = UserPrincipal.FindByIdentity(GetPrincipalContext(), IdentityType.SamAccountName, alias);
    DirectoryEntry directoryEntry = user.GetUnderlyingObject() as DirectoryEntry;
    bool value = null;

    switch (property.ToLower())
    {
        case "enabled":
            value = (user.Enabled == true);
            break;

        case "accountexpire":           
            value = user.AccountExpirationDate() < DateTime.Now;
            break;
           
        case "passwordneverexpires":
            value = (user.PasswordNeverExpires == true);
            break;
    }
    return value;
}



C# Retrieve Get Directory User Attributes

UserPrincipal user = UserPrincipal.FindByIdentity(GetPrincipalContext(), IdentityType.SamAccountName, alias);
if (user != null)
{   
    DirectoryEntry directoryEntry = (user.GetUnderlyingObject() as DirectoryEntry);
    DirectorySearcher adSearch = new DirectorySearcher(directoryEntry);   
    adSearch.SearchScope = SearchScope.Subtree;
    adSearch.Filter = "(&(ObjectClass=user)(sAMAccountName=" + alias + "))";
    SearchResult sResult = adSearch.FindOne();

    if (sResult.Properties.Contains(attribute))
        propertyValue = sResult.Properties[attribute][0].ToString();
}


Monday 16 May 2016

Run a C# .cs file from a Powershell Script

$source =
@"
   public class BasicTest
   {
     public static int Add(int a, int b) {
        return (a + b);
     }

     public int Multiply(int a, int b) {
       return (a * b);
     }
   }
"@

# type definition - must be declared
Add-Type -TypeDefinition $source
 

# access a static method
[BasicTest]::Add(4, 3)

# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)



Wednesday 4 May 2016

Escape text for HTML - Embed Symbols in HTML

ASP.NET 
    var encoded = System.Web.HttpUtility.HtmlEncode(un_encoded);

C# console and Windows apps 
    var encoded = System.Security.SecurityElement.Escape(un_encoded);


Tuesday 12 April 2016

Using Checksums to test for Unexpected Database Schema Changes

USE [DATABASE-NAME]
GO

SELECT CHECKSUM_AGG (CHECKSUM (
                TABLE_NAME,
                COLUMN_NAME,
                CHARACTER_MAXIMUM_LENGTH ))
FROM INFORMATION_SCHEMA.COLUMNS


Thursday 7 April 2016

Database Object Generator

Database Object Generator creates objects for tables in a database. Objects are generated as C# code. Here are two different DataObject Generators:

  • DbObjectGenerator
    Plug-in for Visual Studio. no DLLs, no maintainability issues, and no startup performance cost... more 
  • CodeTrigger
    Code Generation For C#, WPF, WCF, SQL SERVER/ORACLE/MYSQL and Visual Studio 2010-2015... more 

CoffeeScripts

CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way... more


Friday 11 March 2016

CodePen - Playground for the Front End Web

Show off your latest creation and get feedback. Build a test case for that pesky bug. Find example design patterns and inspiration for your projects... more

Emmet — the essential toolkit for web-developers

Emmet is a plugin for many popular text editors which greatly improves HTML & CSS workflow... more


Upgrade Windows 11 Home to Windows 11 Pro

Disable internet connection (Wi-Fi, Internet, etc.) Change the product key using the following Generic product key:                     VK7J...