Talk:UserMgr plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (better formatting)
 
Line 51: Line 51:
}//AddToGroup
}//AddToGroup
</highlight-c>
</highlight-c>
== UserMgr plug-in problem ==
The '''IsMemberOfGroup''' and '''AddToGroup''' does not work, always return '''ERROR 2220''' (means unknown group SID) even if the group exists.
Except this, the following functions from the api; CreateAccount, AddPrivilege and BuiltAccountEnv  works great on WinXP(32) and Win7(64)
Thank you for this  plugin !

Latest revision as of 09:25, 29 October 2010

Thanks for this routine, i use it. However, the function to a group to a user isn't functionnal, it seems to be a windows API problem. I solved this problem using NetLocalGroupAddMembers and modified your dll and it works fine now.

BTW : Your code isn't working with VS8, the problem is swprintf, use MultiByteToWideChar instead. You can contact me at richard.france[nospam]@laposte.net Here is the modified code :

int __declspec(dllexport) AddToGroup(HWND hwndParent, int string_size, 
                                     char *variables, stack_t **stacktop,
                                     extra_parameters *extra)
{
	NET_API_STATUS nStatus = 0;
	WCHAR u_userid[256];
	WCHAR u_groupid[256];
	LPWSTR pUserID;
 
	static char userid[256];
	static char groupid[256];
 
 
	memset( u_userid, 0, sizeof( u_userid ) );
	memset( u_groupid, 0, sizeof( u_groupid ) );
 
	g_hwndParent=hwndParent;
 
	EXDLL_INIT();
 
	popstring(userid);
	popstring(groupid);
 
	MultiByteToWideChar (CP_ACP, 0, userid, -1, u_userid, strlen(userid));
	MultiByteToWideChar (CP_ACP, 0, groupid, -1, u_groupid, strlen(groupid));
 
	pUserID = u_userid;
 
	nStatus = NetLocalGroupAddMembers(NULL, u_groupid , 3,  &pUserID, 1);
 
	if (nStatus == NERR_Success)
	{
		pushstring("OK");
		return 0;
	}
	else
	{
		sprintf(userid, "ERROR %d", nStatus);
		pushstring(userid);
		return nStatus;
	}
}//AddToGroup

UserMgr plug-in problem

The IsMemberOfGroup and AddToGroup does not work, always return ERROR 2220 (means unknown group SID) even if the group exists. Except this, the following functions from the api; CreateAccount, AddPrivilege and BuiltAccountEnv works great on WinXP(32) and Win7(64)

Thank you for this plugin !