Esempio n. 1
0
USHORT MNetGroupDelUser (
    const CHAR FAR * pszServer,
    CHAR       FAR * pszGroupName,
    CHAR       FAR * pszUserName ) {

    return(NetGroupDelUser(pszServer, pszGroupName, pszUserName));

}
Esempio n. 2
0
APIERR MNetGroupDelUser(
	const TCHAR FAR	 * pszServer,
	TCHAR FAR	 * pszGroupName,
	TCHAR FAR	 * pszUserName ) 
{
    return NetGroupDelUser( pszServer,
			    pszGroupName,
			    pszUserName );

}   // MNetGroupDelUser
Esempio n. 3
0
bool RemoveUser(UserManager *panel,bool selection)
{
  bool res=false;
  CFarPanelSelection sp((HANDLE)panel,selection);
  if(sp.Number())
  {
    TCHAR warning[TINY_BUFFER];
    if(sp.Number()==1)
    {
      TCHAR Truncated[MAX_PATH];
      _tcscpy(Truncated,sp[0].FileName);
      FSF.TruncPathStr(Truncated,50);
      FSF.sprintf(warning,GetMsg(mRemoveOne),Truncated);
    }
    else
      FSF.sprintf(warning,GetMsg(mRemoveUserN+NumberType(sp.Number())),sp.Number());
    const TCHAR *MsgItems[]={GetMsg(mButtonRemove),warning,GetMsg(mButtonRemove),GetMsg(mButtonCancel)};
    if(!Info.Message(&MainGuid,&RemoveUserMessageGuid,0,NULL,MsgItems,sizeof(MsgItems)/sizeof(MsgItems[0]),2))
    {
      res=true;
      for(int i=0;i<sp.Number();i++)
      {
        if(sp[i].UserData.FreeData)
        {
          if(panel->global)
          {
            NetGroupDelUser(panel->domain,panel->nonfixed,GetWideNameFromUserData(sp[i].UserData.Data));
          }
          else
          {
            LOCALGROUP_MEMBERS_INFO_0 new_member;
            new_member.lgrmi0_sid=GetSidFromUserData(sp[i].UserData.Data);
            NetLocalGroupDelMembers(panel->computer_ptr,panel->nonfixed,0,(LPBYTE)&new_member,1);
          }
        }
      }
    }
  }
  return res;
}
Esempio n. 4
0
NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
				const char *hostname)
{
	NET_API_STATUS status = 0;
	const char *username, *groupname, *groupname2;
	uint8_t *buffer = NULL;
	struct GROUP_INFO_0 g0;
	uint32_t parm_err = 0;
	uint32_t levels[] = { 0, 1, 2, 3};
	uint32_t enum_levels[] = { 0, 1, 2, 3};
	uint32_t getmem_levels[] = { 0, 1};
	int i;

	printf("NetGroup tests\n");

	username = "******";
	groupname = "torture_test_group";
	groupname2 = "torture_test_group2";

	/* cleanup */
	NetGroupDel(hostname, groupname);
	NetGroupDel(hostname, groupname2);
	NetUserDel(hostname, username);

	/* add a group */

	g0.grpi0_name = groupname;

	printf("testing NetGroupAdd\n");

	status = NetGroupAdd(hostname, 0, (uint8_t *)&g0, &parm_err);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupAdd");
		goto out;
	}

	/* 2nd add must fail */

	status = NetGroupAdd(hostname, 0, (uint8_t *)&g0, &parm_err);
	if (status == 0) {
		NETAPI_STATUS(ctx, status, "NetGroupAdd");
		goto out;
	}

	/* test enum */

	for (i=0; i<ARRAY_SIZE(enum_levels); i++) {

		status = test_netgroupenum(hostname, enum_levels[i], groupname);
		if (status) {
			NETAPI_STATUS(ctx, status, "NetGroupEnum");
			goto out;
		}
	}

	/* basic queries */

	for (i=0; i<ARRAY_SIZE(levels); i++) {

		printf("testing NetGroupGetInfo level %d\n", levels[i]);

		status = NetGroupGetInfo(hostname, groupname, levels[i], &buffer);
		if (status && status != 124) {
			NETAPI_STATUS(ctx, status, "NetGroupGetInfo");
			goto out;
		}
	}

	/* group rename */

	g0.grpi0_name = groupname2;

	printf("testing NetGroupSetInfo level 0\n");

	status = NetGroupSetInfo(hostname, groupname, 0, (uint8_t *)&g0, &parm_err);
	switch (status) {
		case 0:
			break;
		case 50: /* not supported */
		case 124: /* not implemented */
			groupname2 = groupname;
			goto skip_rename;
		default:
			NETAPI_STATUS(ctx, status, "NetGroupSetInfo");
			goto out;
	}

	/* should not exist anymore */

	status = NetGroupDel(hostname, groupname);
	if (status == 0) {
		NETAPI_STATUS(ctx, status, "NetGroupDel");
		goto out;
	}

 skip_rename:
	/* query info */

	for (i=0; i<ARRAY_SIZE(levels); i++) {

		status = NetGroupGetInfo(hostname, groupname2, levels[i], &buffer);
		if (status && status != 124) {
			NETAPI_STATUS(ctx, status, "NetGroupGetInfo");
			goto out;
		}
	}

	/* add user to group */

	status = test_netuseradd(hostname, username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetUserAdd");
		goto out;
	}

	/* should not be member */

	for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {

		status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, NULL);
		if (status) {
			NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
			goto out;
		}
	}

	printf("testing NetGroupAddUser\n");

	status = NetGroupAddUser(hostname, groupname2, username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupAddUser");
		goto out;
	}

	/* should be member */

	for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {

		status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, username);
		if (status) {
			NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
			goto out;
		}
	}

	printf("testing NetGroupDelUser\n");

	status = NetGroupDelUser(hostname, groupname2, username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupDelUser");
		goto out;
	}

	/* should not be member */

	status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
		goto out;
	}

	/* set it again via exlicit member set */

	status = test_netgroupsetusers(hostname, groupname2, 0, 1, &username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
		goto out;
	}

	/* should be member */

	status = test_netgroupgetusers(hostname, 0, groupname2, username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
		goto out;
	}
#if 0
	/* wipe out member list */

	status = test_netgroupsetusers(hostname, groupname2, 0, 0, NULL);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
		goto out;
	}

	/* should not be member */

	status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
		goto out;
	}
#endif
	status = NetUserDel(hostname, username);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetUserDel");
		goto out;
	}

	/* delete */

	printf("testing NetGroupDel\n");

	status = NetGroupDel(hostname, groupname2);
	if (status) {
		NETAPI_STATUS(ctx, status, "NetGroupDel");
		goto out;
	};

	/* should not exist anymore */

	status = NetGroupGetInfo(hostname, groupname2, 0, &buffer);
	if (status == 0) {
		NETAPI_STATUS_MSG(ctx, status, "NetGroupGetInfo", "expected failure and error code");
		goto out;
	};

	status = 0;

	printf("NetGroup tests succeeded\n");
 out:
	if (status != 0) {
		printf("NetGroup testsuite failed with: %s\n",
			libnetapi_get_error_string(ctx, status));
	}

	return status;
}
Esempio n. 5
0
int main(int argc, const char **argv)
{
	NET_API_STATUS status;
	struct libnetapi_ctx *ctx = NULL;
	const char *hostname = NULL;
	const char *groupname = NULL;
	const char *username = NULL;

	poptContext pc;
	int opt;

	struct poptOption long_options[] = {
		POPT_AUTOHELP
		POPT_COMMON_LIBNETAPI_EXAMPLES
		POPT_TABLEEND
	};

	status = libnetapi_init(&ctx);
	if (status != 0) {
		return status;
	}

	pc = poptGetContext("group_deluser", argc, argv, long_options, 0);

	poptSetOtherOptionHelp(pc, "hostname groupname username");
	while((opt = poptGetNextOpt(pc)) != -1) {
	}

	if (!poptPeekArg(pc)) {
		poptPrintHelp(pc, stderr, 0);
		goto out;
	}
	hostname = poptGetArg(pc);

	if (!poptPeekArg(pc)) {
		poptPrintHelp(pc, stderr, 0);
		goto out;
	}
	groupname = poptGetArg(pc);

	if (!poptPeekArg(pc)) {
		poptPrintHelp(pc, stderr, 0);
		goto out;
	}
	username = poptGetArg(pc);

	/* NetGroupDelUser */

	status = NetGroupDelUser(hostname,
				 groupname,
				 username);
	if (status != 0) {
		printf("NetGroupDelUser failed with: %s\n",
			libnetapi_get_error_string(ctx, status));
	}

 out:
	libnetapi_free(ctx);
	poptFreeContext(pc);

	return status;
}