Subscribe

Getting error while using NetUserGetLocalGroups() API

Getting error while using NetUserGetLocalGroups() API. I am using the API to check if the domain user exists in any group.

LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;

        DWORD dwLevel = 0;

        DWORD dwFlags = LG_INCLUDE_INDIRECT ;

        DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;

        DWORD dwEntriesRead = 0;

        DWORD dwTotalEntries = 0;

        NET_API_STATUS nStatus;

        BOOL bAdmin = FALSE;

          

        //

        // Call the NetUserGetLocalGroups function

        //  specifying information level 0.

        //

        //  The LG_INCLUDE_INDIRECT flag specifies that the

        //   function should also return the names of the local

        //   groups in which the user is indirectly a member.

        //

        nStatus = NetUserGetLocalGroups(wszMachineName,

                                        wszUser,

                                        dwLevel,

                                        dwFlags,

                                        (LPBYTE *) &pBuf,

                                        dwPrefMaxLen,

                                        &dwEntriesRead,

                                        &dwTotalEntries);

This call fails with System Error:1726

RPC_S_CALL_FAILED
1726 (0x6BE)

The remote procedure call failed.

Any workaround or suggestions ?