nStatus=NetGroupAddUser(NULL,L"Administrators",L"test1");函数返回值是2220,组没有找到test1已经成功创建,为什么就是加不到administrators组里?拼写已经检查过好几次。CString strAdmin=_T("Administrators");
LPWSTR bstr=strAdmin.AllocSysString();也宣告失败求高手解答

解决方案 »

  1.   

    权限问题?
    1.The NetGroupAddUser function gives an existing user account membership in an existing global group in the security database, which is the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory.2.If you call this function on a domain controller that is running Active Directory, access is allowed or denied based on the access control list (ACL) for the securable object. The default ACL permits only Domain Admins and Account Operators to call this function.
      

  2.   

    如果本机没设成域控制器,应使用NetLocalGroupAddMembers
      

  3.   

    楼上正确。
    NET_API_STATUS nStatus;
    LOCALGROUP_MEMBERS_INFO_3 p;
    p.lgrmi3_domainandname = L"bsi";
    nStatus = NetLocalGroupAddMembers(NULL,L"Administrators",3,(LPBYTE)&p,1);