关于枚举用户信息 比如电脑上有Guest,administrator等账户,我可以用netuserenum将其列出,现在我想得到它们的相应权限请问怎么得到?使用LPUSER_INFO_* (*为数字),还是要其他函数,小弟找不到! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 struct CNetUserInfo{ LPSTR name; LPSTR password; DWORD password_age; DWORD priv; LPSTR home_dir; LPSTR comment; DWORD flags; LPSTR script_path; DWORD auth_flags; LPSTR full_name; LPSTR usr_comment; LPSTR parms; LPSTR workstations; DWORD last_logon; DWORD last_logoff; DWORD acct_expires; DWORD max_storage; DWORD units_per_week; PBYTE logon_hours; DWORD bad_pw_count; DWORD num_logons; LPSTR logon_server; DWORD country_code; DWORD code_page; DWORD user_id; DWORD primary_group_id; LPSTR profile; LPSTR home_dir_drive; BOOL password_expired;};DWORD CNetUsers::GetUserInfo(CString strUserName, CNetUserInfo* pUserInfo){ DWORD dwLevel = 3; LPUSER_INFO_3 pBuf = NULL; NET_API_STATUS nStatus; LPWSTR lpszUserName = (LPWSTR)strUserName.AllocSysString(); LPWSTR lpszServerName = (LPWSTR)m_pDomain.m_strPDC.AllocSysString(); m_strError.Empty(); nStatus = NetUserGetInfo(lpszServerName, lpszUserName, dwLevel, (LPBYTE*)&pBuf); if (nStatus == NERR_Success) { if (pBuf != NULL) { memset(pUserInfo, 0, sizeof(CNetUserInfo)); if(pBuf->usri3_name) { pUserInfo->name = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->name, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->name, pBuf->usri3_name, 256); //pUserInfo->name = szBuff; } if(pBuf->usri3_password) { pUserInfo->password = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->password, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->password, pBuf->usri3_password, 256); //pUserInfo->password = szBuff; } pUserInfo->password_age = pBuf->usri3_password_age; pUserInfo->priv = pBuf->usri3_priv; if(pBuf->usri3_home_dir) { pUserInfo->home_dir = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->home_dir, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->home_dir, pBuf->usri3_home_dir, 256); //pUserInfo->home_dir = szBuff; } if(pBuf->usri3_comment) { pUserInfo->comment = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->comment, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->comment, pBuf->usri3_comment, 256); //pUserInfo->comment = szBuff; } pUserInfo->flags = pBuf->usri3_flags; if(pBuf->usri3_script_path) { pUserInfo->script_path = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->script_path, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->script_path, pBuf->usri3_script_path, 256); } if(pBuf->usri3_full_name) { pUserInfo->full_name = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->full_name, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->full_name, pBuf->usri3_full_name, 256); } if(pBuf->usri3_usr_comment) { pUserInfo->usr_comment = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->usr_comment, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->usr_comment, pBuf->usri3_usr_comment, 256); } if(pBuf->usri3_parms) { pUserInfo->parms = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->parms, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->parms, pBuf->usri3_parms, 256); } if(pBuf->usri3_workstations) { pUserInfo->workstations = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->workstations, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->workstations, pBuf->usri3_workstations, 256); } pUserInfo->max_storage = pBuf->usri3_max_storage; pUserInfo->units_per_week = pBuf->usri3_units_per_week; pUserInfo->logon_hours = pBuf->usri3_logon_hours; pUserInfo->bad_pw_count = pBuf->usri3_bad_pw_count; pUserInfo->num_logons = pBuf->usri3_num_logons; if(pBuf->usri3_logon_server) { pUserInfo->logon_server = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->logon_server, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->logon_server, pBuf->usri3_logon_server, 256); } pUserInfo->country_code = pBuf->usri3_country_code; pUserInfo->code_page = pBuf->usri3_code_page; pUserInfo->user_id= pBuf->usri3_user_id; pUserInfo->primary_group_id = pBuf->usri3_primary_group_id; if(pBuf->usri3_profile) { pUserInfo->profile = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->profile, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->profile, pBuf->usri3_profile, 256); } if(pBuf->usri3_home_dir_drive) { pUserInfo->script_path = (LPSTR)malloc(UNLEN * sizeof(char)); memset(pUserInfo->script_path, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->home_dir_drive, pBuf->usri3_home_dir_drive, 256); } pUserInfo->password_expired = pBuf->usri3_password_expired;; NetApiBufferFree(pBuf); } } SetLastErrorString(nStatus); return nStatus;} 动态生成控件,每次启动都要等待控件生成,如何解决? 求解 Parsing error:Expected")." 一个MFC DLL对话框,每次调用后内存增加4K,算不算正常? 怎样在对话框中绘图、嵌入视图 我建了一个多文档应用程序,如何屏蔽自带的菜单,如文件,查看之类的。急!!! 如何在ATL项目中使用MFC类?? 如何画图? 关于注册表run的问题 MFC 中CAsyncSocket类的OnReceive(); OnConnect() ;OnClose() 改写 为何向ComboBox加选择这么难? VC怎样检测传真机信息? 在多文档程序中实现打开子窗口的功能遇到的问题
{
LPSTR name;
LPSTR password;
DWORD password_age;
DWORD priv;
LPSTR home_dir;
LPSTR comment;
DWORD flags;
LPSTR script_path;
DWORD auth_flags;
LPSTR full_name;
LPSTR usr_comment;
LPSTR parms;
LPSTR workstations;
DWORD last_logon;
DWORD last_logoff;
DWORD acct_expires;
DWORD max_storage;
DWORD units_per_week;
PBYTE logon_hours;
DWORD bad_pw_count;
DWORD num_logons;
LPSTR logon_server;
DWORD country_code;
DWORD code_page;
DWORD user_id;
DWORD primary_group_id;
LPSTR profile;
LPSTR home_dir_drive;
BOOL password_expired;
};
DWORD CNetUsers::GetUserInfo(CString strUserName, CNetUserInfo* pUserInfo)
{ DWORD dwLevel = 3;
LPUSER_INFO_3 pBuf = NULL;
NET_API_STATUS nStatus;
LPWSTR lpszUserName = (LPWSTR)strUserName.AllocSysString();
LPWSTR lpszServerName = (LPWSTR)m_pDomain.m_strPDC.AllocSysString();
m_strError.Empty(); nStatus = NetUserGetInfo(lpszServerName,
lpszUserName,
dwLevel,
(LPBYTE*)&pBuf);
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
memset(pUserInfo, 0, sizeof(CNetUserInfo)); if(pBuf->usri3_name)
{
pUserInfo->name = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->name, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->name, pBuf->usri3_name, 256);
//pUserInfo->name = szBuff;
}
if(pBuf->usri3_password)
{
pUserInfo->password = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->password, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->password, pBuf->usri3_password, 256);
//pUserInfo->password = szBuff;
} pUserInfo->password_age = pBuf->usri3_password_age; pUserInfo->priv = pBuf->usri3_priv;
if(pBuf->usri3_home_dir)
{
pUserInfo->home_dir = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->home_dir, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->home_dir, pBuf->usri3_home_dir, 256);
//pUserInfo->home_dir = szBuff;
} if(pBuf->usri3_comment)
{
pUserInfo->comment = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->comment, 0, UNLEN * sizeof(char)); wcstombs(pUserInfo->comment, pBuf->usri3_comment, 256);
//pUserInfo->comment = szBuff;
} pUserInfo->flags = pBuf->usri3_flags; if(pBuf->usri3_script_path)
{
pUserInfo->script_path = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->script_path, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->script_path, pBuf->usri3_script_path, 256);
} if(pBuf->usri3_full_name)
{
pUserInfo->full_name = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->full_name, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->full_name, pBuf->usri3_full_name, 256);
} if(pBuf->usri3_usr_comment)
{
pUserInfo->usr_comment = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->usr_comment, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->usr_comment, pBuf->usri3_usr_comment, 256);
} if(pBuf->usri3_parms)
{
pUserInfo->parms = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->parms, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->parms, pBuf->usri3_parms, 256);
} if(pBuf->usri3_workstations)
{
pUserInfo->workstations = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->workstations, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->workstations, pBuf->usri3_workstations, 256);
} pUserInfo->max_storage = pBuf->usri3_max_storage; pUserInfo->units_per_week = pBuf->usri3_units_per_week; pUserInfo->logon_hours = pBuf->usri3_logon_hours; pUserInfo->bad_pw_count = pBuf->usri3_bad_pw_count; pUserInfo->num_logons = pBuf->usri3_num_logons; if(pBuf->usri3_logon_server)
{
pUserInfo->logon_server = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->logon_server, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->logon_server, pBuf->usri3_logon_server, 256);
} pUserInfo->country_code = pBuf->usri3_country_code;
pUserInfo->code_page = pBuf->usri3_code_page;
pUserInfo->user_id= pBuf->usri3_user_id;
pUserInfo->primary_group_id = pBuf->usri3_primary_group_id; if(pBuf->usri3_profile)
{
pUserInfo->profile = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->profile, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->profile, pBuf->usri3_profile, 256);
}
if(pBuf->usri3_home_dir_drive)
{
pUserInfo->script_path = (LPSTR)malloc(UNLEN * sizeof(char));
memset(pUserInfo->script_path, 0, UNLEN * sizeof(char));
wcstombs(pUserInfo->home_dir_drive, pBuf->usri3_home_dir_drive, 256);
}
pUserInfo->password_expired = pBuf->usri3_password_expired;; NetApiBufferFree(pBuf);
}
}
SetLastErrorString(nStatus);
return nStatus;
}