Ejemplo n.º 1
0
int _tmain(int argc, _TCHAR* targv[])
#endif
{
    DWORD dwError = 0;

#ifdef _WIN32

    char** allocArgv = NULL;
    PSTR* argv = NULL;
    char pathsep = '\\';

#ifdef UNICODE

    dwError = VmAfdAllocateArgsAFromArgsW( argc, targv, &allocArgv );
    BAIL_ON_VMAFD_ERROR(dwError);
    argv = allocArgv;

#else  /* ifndef UNICODE */

    argv = targv; // non-unicode => targv is char

#endif /* ifdef UNICODE */

#else /* ifndef _WIN32 */

    setlocale(LC_ALL, "");

#endif /* ifdef _WIN32 */

    dwError = ParseArgs(argc, argv);
    BAIL_ON_VMAFD_ERROR(dwError);

cleanup:

    return dwError;

error:

    PrintError (dwError);
    goto cleanup;
}
Ejemplo n.º 2
0
int _tmain(int argc, _TCHAR* targv[])
#endif
{
    DWORD dwError = 0;
    int retCode = 0;
    PCSTR pszErrorMsg = NULL;
    PSTR  pszErrorDesc = NULL;

#ifdef _WIN32

    char** allocArgv = NULL;
    PSTR* argv = NULL;

#ifdef UNICODE

    dwError = VmAfdAllocateArgsAFromArgsW( argc, targv, &allocArgv );
    BAIL_ON_VMAFD_ERROR(dwError);
    argv = allocArgv;

#else  /* ifndef UNICODE */

    argv = targv; // non-unicode => targv is char

#endif /* ifdef UNICODE */

#else /* ifndef _WIN32 */

    setlocale(LC_ALL, "");

#endif /* ifdef _WIN32 */

    dwError = ProcessArgs(argc, argv);
    BAIL_ON_VMAFD_ERROR(dwError);

cleanup:

    VMAFD_SAFE_FREE_STRINGA(pszErrorDesc);
    return dwError;

error:

    switch (dwError)
    {
        case ERROR_CANNOT_CONNECT_VMAFD:
            retCode = 20;
            pszErrorMsg = "Could not connect to the local service VMware AFD.\nVerify VMware AFD is running.";
            break;
        case VMDIR_ERROR_CANNOT_CONNECT_VMDIR:
            retCode = 21;
            pszErrorMsg = "Could not connect to the local service VMware Directory Service.\nVerify VMware Directory Service is running.";
            break;
        case ERROR_INVALID_CONFIGURATION:
            retCode = 22;
            pszErrorMsg = "Configuration is not correct.\nFirst boot scripts need to be executed.";
            break;
        case VMDIR_ERROR_SERVER_DOWN:
            retCode = 23;
            pszErrorMsg = "Could not connect to VMware Directory Service via LDAP.\nVerify VMware Directory Service is running on the appropriate system and is reachable from this host.";
            break;
        case VMDIR_ERROR_USER_INVALID_CREDENTIAL:
            retCode = 24;
            pszErrorMsg = "Authentication to VMware Directory Service failed.\nVerify the username and password.";
            break;
        case ERROR_ACCESS_DENIED:
            retCode = 25;
            pszErrorMsg = "Authorization failed.\nVerify account has proper administrative privileges.";
            break;
        case ERROR_INVALID_DOMAINNAME:
            retCode = 26;
            pszErrorMsg = "Failed to join the domain.\nThe domain name specified is invalid.";
            break;
        case ERROR_NO_SUCH_DOMAIN:
            retCode = 27;
            pszErrorMsg = "Failed to join the domain.\nA domain controller for the domain could not be located. Verify the DNS settings pertaining to this domain name.";
            break;
        case ERROR_PASSWORD_RESTRICTION:
            retCode = 28;
            pszErrorMsg = "Failed to join the domain.\nA required password was not specified or did not match complexity requirements.";
            break;
        case ERROR_HOST_DOWN:
            retCode = 29;
            pszErrorMsg = "Failed to join the domain.\nThe required service on the domain controller is unreachable.";
            break;
        default:
            retCode = 1;
    }

    if (retCode != 1)
    {
        fprintf(
            stderr,
            "domain-join failed, error= %s %u\n",
            pszErrorMsg,
            dwError);
    }
    else
    {
        if (!VmAfdGetErrorString(dwError, &pszErrorDesc))
        {
            fprintf(stderr, "domain-join failed. Error %u: %s \n", dwError, pszErrorDesc);
        }
        else
        {
            fprintf(stderr, "domain-join failed with error: %u\n", dwError);
        }
    }

    goto cleanup;
}