[#2212] CID49416:

Split null check and arg count check into two checks to make username ==
NULL a sufficient condition for failure
[#2212] CID49415:

removed duplicated code
[#2212] CID49414:

Added null check
[#2212] CID49411:

Added null checks
[#2212] CID49408:

Added null check