Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is the coding is for accessing the domain.

but its not working properly..

it producing error as "domain name not found"

what i want to do now..

C++
#include "stdafx.h"
#include <windows.h>
#include <Winsock2.h>
#include <Lm.h>
#include <string.h>
#include <iostream.h>
int main()
{
    WSADATA D;
    int iReturn;
    DWORD size = 1000;
    DWORD count = 0;
    DWORD tries = 0;
    iReturn = WSAStartup(MAKEWORD(2,2),&D);
    if(0 == iReturn)
        printf("The sucess\n");
    else
        printf("\nThe error%d\n",WSAGetLastError);
    wchar_t *server = NULL;
    wchar_t *groupName = L"Workgroup"; // global group name
    DWORD rc, pref, got, total, resumeh = 0;
    GROUP_USERS_INFO_0 *buf;
    pref = 16; // start low, get more later
    buf = NULL; // important!
    do
    {
        pref *= 2; // bump buffer size
        printf( "Trying with prefmaxlen == %lu bytes\n", pref );
        if ( buf != NULL )
        {
            NetApiBufferFree( buf );
            buf = NULL; // important!
        }
        rc = NetGroupGetUsers( server, groupName, 0, (LPBYTE *) &buf, pref, &got, &total, &resumeh );
    } while ( rc == NERR_BufTooSmall || rc == ERROR_MORE_DATA );
    if(rc != 0)
    {
        printf("Duh! -- error %lu\n", rc);
    }
    for ( rc = 0; buf != NULL && rc < got; rc ++ )
    {
        printf("\nhai\n");
            printf( "%S\n", buf[rc].grui0_name ); // %S: cap-S toggles Unicode/ANSI
    }
    if ( buf != NULL )
        NetApiBufferFree( buf );
    return 0;
}
Posted
Updated 26-Jul-11 3:42am
v2
Comments
Richard MacCutchan 26-Jul-11 9:43am    
What line produces this error message?
Dhanasundhari 27-Jul-11 1:47am    
sir.. thanks for the comments sir..

i found the error and find the solution sir.

Thanks sir.

1 solution

if you read the doc:

"servername [in] A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used."

http://msdn.microsoft.com/en-us/library/aa370430(v=vs.85).aspx[^]

You have to adress the server on which it runs
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900