Verifying Active Directory Installation

Check the status of the shared SYSVOL

dcdiag /test:netlogons

Verify DNS registration and functionality

dcdiag /test:dns

Verify communication with other domain controllers

nltest /dclist: <domain name>

Verify replication with other domain controllers

dcdiag /test:replications

Verify the availability of the operations masters

dcdiag /s: domaincontroller /test:knowsofroleholders /verbose 
dcdiag /s: domaincontroller /test:fsmocheck

[via]https://technet.microsoft.com/en-us/library/cc781459%28v=ws.10%29.aspx[/via]

Store VMware PowerCLI login credentials

Connect to VirtualCenter Server and enter credentials

Connect-VIServer -Server <Server>

Save the credentials to the credential store file (By default the credential store file is stored - encrypted - under the user profile directory)

New-VICredentialStoreItem  -Host <Server> -User "<Username>" -Password "<Password>"

[via]https://blogs.vmware.com/PowerCLI/2011/11/have-you-seen-powerclis-credential-store-feature.html[/via]

How to repair or fully rebuild Windows WMI Repository

For Windows Vista and newer try to run the following:

  1. Verify repo (If the result shown as inconsistent, go to step 2)
    winmgmt /verifyrepository
  2. Repair repo
    winmgmt /salvagerepository
  3. Verify repo to check again wmi repository had been repaired successfully
    winmgmt /verifyrepository

To fully rebuild the WMI Repository follow these steps:

  1. Disable and stop the winmgmt service (Disable is important, elso you can't rename the folder in step 2)
  2. Rename C:\Windows\System32\wbem\repository
  3. Enable and start the winmgmt service
  4. Open a CMD prompt as Administrator
  5. Navigate to C:\Windows\System32\wbem\
  6. Run the cmd (this will take a minute or so to complete)
    for /f %s in ('dir /b *.mof') do mofcomp %s
  7. Now run the cmd
    for /f %s in ('dir /b en-us\*.mfl') do mofcomp en-us\%s
  8. Now run the cmd
    for /f %s in ('dir /b de-DE\*.mfl') do mofcomp de-DE\%s
  9. Restart computer

[via]https://support.software.dell.com/de-de/vworkspace/kb/88861[/via]

MySQL: UPDATE query based on SELECT query

update tableA a
left join tableB b on
    a.name_a = b.name_b
set
    validation_check = if(start_dts > end_dts, 'VALID', '')
UPDATE payments p 
    INNER JOIN users u ON
    p.pay_id=u.user_id
SET 
    p.pay_email=u.user_email, 
    p.pay_firstname=u.user_firstname, 
    p.pay_lastname=u.user_lastname, 
    p.pay_date=u.user_date

[via]http://stackoverflow.com/a/1262848[/via]

PHP Password dos and don’ts

Don'ts

  • Don't limit what characters users can enter for passwords. Only idiots do this.
  • Don't limit the length of a password. If your users want a sentence with supercalifragilisticexpialidocious in it, don't prevent them from using it.
  • Never store your user's password in plain-text.
  • Never email a password to your user except when they have lost theirs, and you sent a temporary one.
  • Never, ever log passwords in any manner.
  • Never hash passwords with SHA1 or MD5 or even SHA256! Modern crackers can exceed 60 and 180 billion hashes/second (respectively).
  • Don't mix bcrypt and with the raw output of hash(), either use hex output or base64_encode it. (This applies to any input that may have a rogue \0 in it, which can seriously weaken security.)

Dos

  • Use scrypt when you can; bcrypt if you cannot.
  • Use PBKDF2 if you cannot use either bcrypt or scrypt, with SHA2 hashes.
  • Reset everyone's passwords when the database is compromised.
  • Implement a reasonable 8-10 character minimum length, plus require at least 1 upper case letter, 1 lower case letter, a number, and a symbol. This will improve the entropy of the password, in turn making it harder to crack. (See the "What makes a good password?" section for some debate.)

PHP

// Generate or return salted passwords
function crypt2($password, $salt = "") {

    if($salt == "") {
        // A higher "cost" is more secure but consumes more processing power
        $cost = 10;
        
        // Create a random salt
        $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');

        // Prefix information about the hash so PHP knows how to verify it later.
        // "$2a$" Means we're using the Blowfish algorithm. The following two digits are the cost parameter.
        $salt = sprintf("$2a$%02d$", $cost) . $salt;
    }
        
    // Hash the password with the salt
    $hash = crypt($password, $salt);

    return $hash;
    
}
// Save password
$hash = crypt2($user_password); // hash the password with salt
dbquery("UPDATE users SET user_hash='".$hash."' WHERE user_id='1'");
// Login
$sql = "SELECT user_hash FROM users WHERE user_loginname='Admin' LIMIT 1";
[...]
$data = dbarray($result);

if (hash_equals($data['user_hash'], crypt2($user_pass, $data['user_hash']))) {
    // Ok!
}

[via]http://stackoverflow.com/questions/401656/secure-hash-and-salt-for-php-passwords/, https://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/[/via]

white-space: pre-warp don’t work at Internet Explorer

Today i noticed that our Knowledge Base looks ugly at Internet Explorer. It seems that he ignoring the following CSS attribute:

white-space: pre-warp

After a few test I found out, that by default IE use for intranet page the compatibility mode. OMG...

There are two ways to change this. First you can add a meta attribute the every page:

<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

or you can use the Apache Module mod_headers which is my choise:
1. Change Apache2 Config to load the headers_module

LoadModule headers_module modules/mod_headers.so
  1. Change now the vhost.conf and add the Header
Header set X-UA-Compatible “IE=Edge”
  1. Reload Apache2

ODD drive is not recognized in Windows 8.x/10

After you install Windows 8.x or Windows 10, you may find the CD/DVD drive is not recognized. Resolution:

Open Command Prompt as an Administrator and run the following command:

reg.exe add "HKLM\System\CurrentControlSet\Services\atapi\Controller0" /f /v EnumDevice1 /t REG_DWORD /d 0x00000001

Reboot the system and verify if the problem has been resolved.
[via]http://blogs.technet.com/b/asiasupp/archive/2012/03/22/you-may-experience-that-dvd-drive-is-not-recognized-in-windows-8.aspx[/via]