Wednesday 27 March 2013

To identify the mpm module loaded for an Apache server under windows

>"C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" -l

Compiled in modules:
  core.c
  mod_win32.c
  mpm_winnt.c
  http_core.c
  mod_so.c

Thursday 21 March 2013

Displaying Solutions for ASP.NET web applications

Visual Studio --> Tools --> Options



Validating users using password, hash and salt


DB Fields:
Table User: Columns (UserName, Password, Salt)


Public Shared Function GetPasswordHash(Password As String, Salt As String) As String
Dim StringEncoder As New UTF8Encoding()
Dim Bytes_Password As Byte() = StringEncoder.GetBytes(Password)
Dim Bytes_Salt As Byte() = StringEncoder.GetBytes(Salt)

' Array for password & salt
Dim Bytes_Password_Salt As Byte() = New Byte(Bytes_Password.Length + Bytes_Salt.Length - 1) {}

For i As Integer = 0 To Bytes_Password.Length - 1
    Bytes_Password_Salt(i) = Bytes_Password(i)
Next

For i As Integer = 0 To Bytes_Salt.Length - 1
      Bytes_Password_Salt(i + Bytes_Password.Length) = Bytes_Salt(i)
Next

Dim MD5Provider As New MD5CryptoServiceProvider
Dim Bytes_Hash As Byte() = MD5Provider.ComputeHash(Bytes_Password_Salt)
Dim String_Hash As String = Convert.ToBase64String(Bytes_Hash)

Return String_Hash
End Function

Public Shared Function ValidateUser(UserName As String, Password As String) As Boolean
Dim IsValidUser As Boolean = False

Dim Cmd As New SqlCommand()
Cmd.CommandText = "SELECT [Password] PassHash, Salt AS Salt FROM [User] WHERE UPPER(UserName) = UPPER(@UserName) "
Cmd.CommandType = Data.CommandType.Text

Cmd.Parameters.AddWithValue("UserName", UserName)

Dim ds As DataSet = DBHelper.RunSQLQuery(Cmd)

Dim StoredHash As String = Nothing
Dim StoredSalt As String = Nothing
If ds.Tables.Count = 1 Then
    If ds.Tables(0).Rows.Count = 1 Then

       Dim CurrentRow As DataRow = ds.Tables(0).Rows(0)
       If Not IsDBNull(CurrentRow("PassHash")) Then
               StoredHash = CurrentRow("PassHash")
        End If

       If Not IsDBNull(CurrentRow("Salt")) Then
                StoredSalt = CurrentRow("Salt")
       End If
   End If
End If

If Not IsNothing(StoredHash) And Not IsNothing(StoredSalt) Then
   Dim CalculatedHash As String = GetPasswordHash(Password, StoredSalt)
   If CalculatedHash = StoredHash Then
        IsValidUser = True
   End If
End If

Return IsValidUser
End Function


Public Shared Function RunSQLQuery(ByVal Cmd As SqlCommand) As System.Data.DataSet
Dim s As New System.Data.DataSet()

Cmd.Connection = New SqlConnection(ConnectionString)
Dim a As New System.Data.SqlClient.SqlDataAdapter(Cmd)
a.Fill(s)

Return s
End Function

Thursday 14 March 2013

Setting wireless networks priorities for Windows



1) Display list of current profiles:
>netsh wlan show profiles

Profiles on interface Wireless Network Connection:

Group policy profiles (read only)
---------------------------------
    <None>

User profiles
-------------
  

    All User Profile     : BASIC_IBIS

    All User Profile     : Belkin

    All User Profile     : Serena-WiFi

    All User Profile     : MOBILE


    All User Profile     : belkin54g


2) Change profiles priority:

>netsh wlan set profileorder name="Belkin" interface="Wireless Network Connection" priority=1
Priority order of profile "Belkin" is updated successfully.

C:\Users\sawafa.EMRO>netsh wlan show profiles

Profiles on interface Wireless Network Connection:

Group policy profiles (read only)
---------------------------------
    <None>

User profiles
-------------
    All User Profile     : Belkin
    All User Profile     : BASIC_IBIS
    All User Profile     : Serena-WiFi
    All User Profile     : MOBILE
    All User Profile     : belkin54g
 


Monday 11 March 2013

Merge Outlook calendars together

Easy like copy & paste, the trick is to change the view to accept copy\paste:

Open the seconary calendar to merge:
- "View" from the menu
- "Chnage View" from the Ribbon
- "List" from the submenu
- Select All "Ctrl+A" then "Ctrl+C"
- Move to destination calendar "Ctrl+V"


Sunday 10 March 2013

Feature I would not like to see in: iOS 6 tests stop the functionality for my iPhone 4S WiFi & Bluetooth

If that was what they call an update, I no longer want similar Apple updates!

Apple staff replies to my queries regarding the cause for my issue is that my device might originally had this H\W defect and the iOS upgrade might have included further tests which resulted in its detection and no longer enables the H\W to function!

Story starts, or as far as I understand (since although I believe it is attributed to the update, I can't claim I am pretty sure), shortly following my iOS 6 update:


1- iOS update installed smoothly and I have no problem for a week or so.
2- Using the Bluetooth in my car as usual, and between my calls, Bluetooth stopped functioning. Meaning that I completed a call with Bluetooth hands-free and my next call few minutes after that, the call was only through my device and I noticed it was disconnected from the car system.
3- Several trials to shutdown and start the device, hard restart the iPhone  and restarting\resetting my car audio system, with no success.(Only the spinning Bluetooth wheel.)
4- My big shock was that the WiFi button was completely disabled.
5- So much frustrated now, I backup-ed the device, and restored, backup-ed up and wiped it completely off. I found no way to downgrade. No Hope, at all!
6- Headed to the apple store, heard the explanation above and had it exchanged for another refurbished device.
For your info: Out of warranty exchange price: [Price CHF 209]