예제 #1
0
VOID
LWNetDnsFreeRecord(
    IN OUT PDNS_RECORD pRecord
    )
{
    LWNET_SAFE_FREE_STRING(pRecord->pszName);
    LWNetFreeMemory(pRecord);
}
예제 #2
0
VOID
LWNetDnsFreeSRVInfoRecord(
    IN OUT PDNS_SRV_INFO_RECORD pRecord
    )
{
    LWNET_SAFE_FREE_STRING(pRecord->pszAddress);
    LWNET_SAFE_FREE_STRING(pRecord->pszTarget);
    LWNetFreeMemory(pRecord);
}
예제 #3
0
void
LWNetSrvCloseServer(
    HANDLE hServer
    )
{
    PLWNET_SRV_API_STATE pServerState = (PLWNET_SRV_API_STATE)hServer;

    if (pServerState->hEventLog != (HANDLE)NULL)
    {
       LWNetSrvCloseEventLog(pServerState->hEventLog);
    }
    
    LWNetFreeMemory(pServerState);
}
예제 #4
0
LWNET_API
LW_VOID
LWNetFreeDCList(
    LW_IN LW_OUT PLWNET_DC_ADDRESS pDcList,
    LW_IN DWORD dwDcCount
    )
{
    DWORD i = 0;
    for (i = 0; i < dwDcCount; i++)
    {
        LWNET_SAFE_FREE_STRING(pDcList[i].pszDomainControllerName);
        LWNET_SAFE_FREE_STRING(pDcList[i].pszDomainControllerAddress);
    }
    LWNetFreeMemory(pDcList);
}
예제 #5
0
LWNET_API
VOID
LWNetFreeDCInfo(
    PLWNET_DC_INFO pDCInfo
    )
{
    
    LWNET_SAFE_FREE_STRING(pDCInfo->pszDomainControllerName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszDomainControllerAddress);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszNetBIOSDomainName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszFullyQualifiedDomainName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszDnsForestName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszDCSiteName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszClientSiteName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszNetBIOSHostName);
    LWNET_SAFE_FREE_STRING(pDCInfo->pszUserName);

    LWNetFreeMemory(pDCInfo);
}
예제 #6
0
파일: dcfinder.c 프로젝트: vmware/lightwave
DWORD
VmAfdGetDomainController(
    PCSTR pszDomain,
    PCSTR pszUserName,
    PCSTR pszPassword,
    PCSTR pszSiteName,          /* OPTIONAL */
    PSTR* ppszHostname,
    PSTR* ppszNetworkAddress
    )
{
    DWORD dwError = 0;
    PDNS_SERVER_INFO pServerArray = NULL;
    DWORD dwServerCount = 0;
    PSTR  pszQuestion = NULL;
    DWORD dwDsFlags = 0;
    PSTR  pszNetworkAddress = NULL;
    PSTR  pszHostname = NULL;
    PSTR  pszUPN = NULL;
    PSTR  pszDomainDN = NULL;

    if (IsNullOrEmptyString(pszDomain) || !ppszHostname || !ppszNetworkAddress)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    if (IsNullOrEmptyString(pszSiteName))
    {
        dwError = VmAfdAllocateStringPrintf(
                            &pszQuestion,
                            "_ldap._tcp.%s",
                            pszDomain);
        BAIL_ON_VMAFD_ERROR(dwError);
    }
    else
    {
        dwError = VmAfdAllocateStringPrintf(
                            &pszQuestion,
                            "_ldap._tcp.%s._sites.%s",
                            pszSiteName,
                            pszDomain);
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    dwError = LWNetDnsSrvQueryByQuestion(
                    pszQuestion,
                    NULL,
                    dwDsFlags,
                    &pServerArray,
                    &dwServerCount);
    BAIL_ON_VMAFD_ERROR(dwError);

    if (dwServerCount > 0)
    {
        DWORD iServer = 0;

        dwError = VmAfdAllocateStringPrintf(
                      &pszUPN,
                      "%s@%s",
                      pszUserName,
                      pszDomain);
        BAIL_ON_VMAFD_ERROR(dwError);

        dwError = VmAfSrvGetDomainDN(pszDomain, &pszDomainDN);
        BAIL_ON_VMAFD_ERROR(dwError);

        for (; iServer < dwServerCount; iServer++)
        {
            DWORD dwError2 = 0;
            PDNS_SERVER_INFO pServerInfo = &pServerArray[iServer];

            dwError2 = VmAfSrvCheckDC(
                            pServerInfo,
                            pszDomainDN,
                            pszUPN,
                            pszPassword,
                            &pszHostname,
                            &pszNetworkAddress);
            if (dwError2 == ERROR_SUCCESS)
            {
                break;
            }
        }
    }

    if (!pszNetworkAddress || !pszHostname)
    {
        dwError = ERROR_NO_SUCH_DOMAIN;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    *ppszHostname = pszHostname;
    *ppszNetworkAddress = pszNetworkAddress;

cleanup:

    if (pServerArray)
    {
        LWNetFreeMemory(pServerArray);
    }
    VMAFD_SAFE_FREE_MEMORY(pszQuestion);
    VMAFD_SAFE_FREE_MEMORY(pszUPN);
    VMAFD_SAFE_FREE_MEMORY(pszDomainDN);

    return dwError;

error:

    if (ppszNetworkAddress)
    {
        *ppszNetworkAddress = NULL;
    }

    VMAFD_SAFE_FREE_MEMORY(pszHostname);
    VMAFD_SAFE_FREE_MEMORY(pszNetworkAddress);

    goto cleanup;
}
예제 #7
0
파일: dcfinder.c 프로젝트: vmware/lightwave
DWORD
VmAfdGetDomainControllerList(
    PCSTR pszDomain,
    PVMAFD_DC_INFO_W *ppVmAfdDCInfoList,
    PDWORD pdCount
    )
{
    DWORD dwError = 0;
    DWORD dwIndex = 0;
    PDNS_SERVER_INFO pServerArray = NULL;
    DWORD dwServerCount = 0;
    PSTR  pszQuestion = NULL;
    DWORD dwDsFlags = 0;
    PSTR  pszUPN = NULL;
    PSTR  pszDomainDN = NULL;
    PVMAFD_DC_INFO_W pVmAfdDCEntries = NULL;

    if (IsNullOrEmptyString(pszDomain) || !ppVmAfdDCInfoList)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    dwError = VmAfdAllocateStringPrintf(
                    &pszQuestion,
                    "_ldap._tcp.%s",
                    pszDomain);
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = LWNetDnsSrvQueryByQuestion(
                    pszQuestion,
                    NULL,
                    dwDsFlags,
                    &pServerArray,
                    &dwServerCount);
    BAIL_ON_VMAFD_ERROR(dwError);

    if (dwServerCount > 0 )
    {
        dwError = VmAfdAllocateMemory(
                            sizeof(VMAFD_DC_INFO_W)*dwServerCount,
                            (PVOID *)&pVmAfdDCEntries
                            );
        BAIL_ON_VMAFD_ERROR(dwError);

       for (; dwIndex < dwServerCount; dwIndex++)
       {
           PDNS_SERVER_INFO pServerInfo = &pServerArray[dwIndex];
           PVMAFD_DC_INFO_W pDcInfo = &pVmAfdDCEntries[dwIndex];

           dwError = VmAfdAllocateStringWFromA(
                                       pServerInfo->pszName,
                                       &pDcInfo->pwszHostName
                                       );
           BAIL_ON_VMAFD_ERROR(dwError);

           dwError = VmAfdAllocateStringWFromA(
                                        pServerInfo->pszAddress,
                                        &pDcInfo->pwszAddress
                                        );
           BAIL_ON_VMAFD_ERROR(dwError);
       }
    }
    *pdCount = dwServerCount;
    *ppVmAfdDCInfoList = pVmAfdDCEntries;
cleanup:

    if (pServerArray)
    {
        LWNetFreeMemory(pServerArray);
    }
    VMAFD_SAFE_FREE_MEMORY(pszQuestion);
    VMAFD_SAFE_FREE_MEMORY(pszUPN);
    VMAFD_SAFE_FREE_MEMORY(pszDomainDN);

    return dwError;

error:
   if (dwServerCount > 0 && pVmAfdDCEntries )
   {
      for (dwIndex = 0; dwIndex < dwServerCount ; dwIndex++)
      {
          PVMAFD_DC_INFO_W pDcInfo = &pVmAfdDCEntries[dwIndex];
          if (pDcInfo)
          {
              VMAFD_SAFE_FREE_MEMORY(pDcInfo->pwszHostName);
              VMAFD_SAFE_FREE_MEMORY(pDcInfo->pwszAddress);
          }
      }
   }
   VMAFD_SAFE_FREE_MEMORY(pVmAfdDCEntries);
   goto cleanup;

}