Example #1
0
DWORD
VmwDeploySetupInstance(
    PVMW_IC_SETUP_PARAMS pParams
    )
{
    DWORD dwError = 0;

    if (!pParams)
    {
        VMW_DEPLOY_LOG_ERROR("No setup parameters specified");

        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

    if (!VmwDeployHaveAdminRights())
    {
        VMW_DEPLOY_LOG_ERROR("User does not have administrative rights");

        dwError = ERROR_ACCESS_DENIED;
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

    switch (pParams->dir_svc_mode)
    {
        case VMW_DIR_SVC_MODE_STANDALONE:

            dwError = VmwDeploySetupServerPrimary(pParams);

            break;

        case VMW_DIR_SVC_MODE_PARTNER:

            dwError = VmwDeploySetupServerPartner(pParams);

            break;

        case VMW_DIR_SVC_MODE_CLIENT:

            dwError = VmwDeploySetupClient(pParams);

            break;

        default:

            dwError = ERROR_INVALID_PARAMETER;

            break;
    }
    BAIL_ON_DEPLOY_ERROR(dwError);

error:

    return dwError;
}
Example #2
0
DWORD
VmwDeployValidatePassword(
    PCSTR pszPassword
    )
{
    DWORD dwError = 0;
    size_t iCh = 0;
    size_t nUpper = 0;
    size_t nLower = 0;
    size_t nDigit = 0;
    size_t nSpecial = 0;
    size_t sLen = 0;

    VMW_DEPLOY_LOG_DEBUG("Validating password");

    if (IsNullOrEmptyString(pszPassword) || (sLen = strlen(pszPassword)) < 8)
    {
        dwError = ERROR_PASSWORD_RESTRICTION;
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

    // We are looking for at least one upper case, one lower case, one digit and
    // one special case character. Added illegal chars check
    for (iCh = 0; iCh < sLen; iCh++)
    {
        int ch = pszPassword[iCh];

        if (isdigit(ch))
        {
            nDigit++;
        }
        else if (islower(ch))
        {
            nLower++;
        }
        else if (isupper(ch))
        {
            nUpper++;
        }
        else if (ispunct(ch))
        {
            nSpecial++;
        }
    }

    if (!nUpper || !nLower || !nDigit || !nSpecial)
    {
        VMW_DEPLOY_LOG_ERROR("Password complexity requirement not satisfied");

        dwError = ERROR_PASSWORD_RESTRICTION;
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

error:

    return dwError;
}
Example #3
0
DWORD
VmwDeployValidateSiteName(
    PCSTR pszSite
    )
{
    DWORD dwError = 0;
    BOOLEAN bHasSpecialChars = FALSE;

    VMW_DEPLOY_LOG_DEBUG(
            "Validating site name [%s]",
            VMW_DEPLOY_SAFE_LOG_STRING(pszSite));

    if (!IsNullOrEmptyString(pszSite))
    {
        PCSTR pszCursor = pszSite;

        while (*pszCursor && !bHasSpecialChars)
        {
            switch (*pszCursor)
            {
                case '!':
                case '@':
                case '#':
                case '$':
                case '%':
                case '^':
                case '&':
                case '*':
                case '[':
                case ']':
                     bHasSpecialChars = TRUE;
                     break;
                default:
                     pszCursor++;
                     break;
            }
        }
    }

    if (bHasSpecialChars)
    {
        VMW_DEPLOY_LOG_ERROR(
                "Site name [%s] has invalid characters",
                VMW_DEPLOY_SAFE_LOG_STRING(pszSite));

        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

error:

    return dwError;
}
Example #4
0
DWORD
VmwDeployValidateHostname(
    PCSTR pszHostname
    )
{
    DWORD dwError = 0;

    VMW_DEPLOY_LOG_DEBUG(
            "Validating hostname [%s]", 
            VMW_DEPLOY_SAFE_LOG_STRING(pszHostname));

    if (IsNullOrEmptyString(pszHostname) ||
        !strcmp(pszHostname, "localhost") ||
        !strcmp(pszHostname, "localhost.localdom"))
    {
        dwError = ERROR_INVALID_NETNAME;

        VMW_DEPLOY_LOG_ERROR(
            "Error : Invalid hostname [%s]", 
            VMW_DEPLOY_SAFE_LOG_STRING(pszHostname));
    }

    return dwError;
}
Example #5
0
int
LightwaveDomainPromote(
    int argc,
    char* argv[])
{
    DWORD dwError = 0;
    PVMW_IC_SETUP_PARAMS pSetupParams = NULL;
    PVMW_DEPLOY_LOG_CONTEXT pContext = NULL;
    int retCode = 0;
    PSTR pszErrorMsg = NULL;
    PSTR pszErrorDesc = NULL;
    DWORD dwError2 = 0;

    if (argc == 0 || argv[0] == NULL || !strcmp(argv[0], "--help"))
    {
        ShowUsage();
        goto cleanup;
    }

    setlocale(LC_ALL, "");

    dwError = VmwDeployInitialize();
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = ParseArgs(argc, argv, &pSetupParams);
    if (dwError)
    {
        ShowUsage();
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

    dwError = VmwDeployCreateLogContext(
                    VMW_DEPLOY_LOG_TARGET_FILE,
                    VMW_DEPLOY_LOG_LEVEL_INFO,
                    ".",
                    &pContext);
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = VmwDeploySetLogContext(pContext);
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = VmwDeploySetupInstance(pSetupParams);
    BAIL_ON_DEPLOY_ERROR(dwError);

    fprintf(stdout, "Domain Controller setup was successful\n");

cleanup:

    if (pSetupParams)
    {
        VmwDeployFreeSetupParams(pSetupParams);
    }
    if (pContext)
    {
        VmwDeployReleaseLogContext(pContext);
    }
    VmwDeployShutdown();

    return dwError;

error:

    dwError2 = VmwDeployGetError(
                     dwError,
                     &pszErrorMsg,
                     &retCode);
    if (dwError2 || retCode == 1)
    {
        if (!VmAfdGetErrorMsgByCode(dwError, &pszErrorDesc))
        {
            fprintf(stderr, "Domain controller setup failed. Error %u: %s \n", dwError, pszErrorDesc);
        }
        else
        {
            fprintf(stderr, "Domain controller setup failed with error: %u\n", dwError);
        }
    }
    else
    {
        fprintf(
            stderr,
            "Domain controller setup failed, error= %s %u\n",
            pszErrorMsg,
            dwError);
    }

    VMW_DEPLOY_LOG_ERROR("Domain controller setup failed. Error code: %u", dwError);

    if (pszErrorMsg)
    {
        VmwDeployFreeMemory(pszErrorMsg);
        pszErrorMsg = NULL;
    }

    goto cleanup;
}
Example #6
0
int main(int argc, char* argv[])
{
    DWORD dwError = 0;
    PVMW_IC_SETUP_PARAMS pSetupParams = NULL;
    PVMW_DEPLOY_LOG_CONTEXT pContext = NULL;
    int retCode = 0;
    PSTR pszErrorMsg = NULL;
    PSTR pszErrorDesc = NULL;

    setlocale(LC_ALL, "");

    dwError = VmwDeployInitialize();
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = ParseArgs(argc-1, &argv[1], &pSetupParams);
    if (dwError)
    {
        ShowUsage();
        BAIL_ON_DEPLOY_ERROR(dwError);
    }

    dwError = VmwDeployCreateLogContext(
                    VMW_DEPLOY_LOG_TARGET_FILE,
                    VMW_DEPLOY_LOG_LEVEL_INFO,
                    ".",
                    &pContext);
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = VmwDeploySetLogContext(pContext);
    BAIL_ON_DEPLOY_ERROR(dwError);

    dwError = VmwDeploySetupInstance(pSetupParams);
    BAIL_ON_DEPLOY_ERROR(dwError);

    fprintf(stdout, "Domain Controller setup was successful\n");

cleanup:

    if (pSetupParams)
    {
        VmwDeployFreeSetupParams(pSetupParams);
    }
    if (pContext)
    {
        VmwDeployReleaseLogContext(pContext);
    }
    VmwDeployShutdown();

    return dwError;

error:

    switch (dwError)
    {

    case ERROR_INVALID_PARAMETER:
        retCode = 2;
        pszErrorMsg = "Invalid parameter was given.";
        break;
    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.\n";
        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 = "The domain name specified is invalid.";
        break;
    case ERROR_NO_SUCH_DOMAIN:
        retCode = 27;
        pszErrorMsg = "A domain controller for the given domain could not be located.";
        break;
    case ERROR_PASSWORD_RESTRICTION:
        retCode = 28;
        pszErrorMsg = "A required password was not specified or did not match complexity requirements.";
        break;
    case ERROR_HOST_DOWN:
        retCode = 29;
        pszErrorMsg = "The required service on the domain controller is unreachable.";
        break;
    case VMDIR_ERROR_SCHEMA_NOT_COMPATIBLE:
        retCode = 30;
        pszErrorMsg = "Could not join to the remote service VMWare Directory Service.\nThe remote schema is incompatible with the local schema.";
        break;
    default:
        retCode = 1;
    }

    if (retCode != 1)
    {
        fprintf(
            stderr,
            "Domain controller setup failed, error= %s %u\n",
            pszErrorMsg,
            dwError);
    }
    else
    {
        if (!VmAfdGetErrorMsgByCode(dwError, &pszErrorDesc))
        {
            fprintf(stderr, "ic-promoteDomain controller setup failed. Error %u: %s \n", dwError, pszErrorDesc);
        }
        else
        {
            fprintf(stderr, "Domain controller setup ic-promote failed with error: %u\n", dwError);
        }
    }

    VMW_DEPLOY_LOG_ERROR("Domain controller setup failed. Error code: %u", dwError);

    goto cleanup;
}