/////////////////////////////////////////////////////////////////////
// 
// Function:    
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT CAGetAdministratorsGroupName::OnExecution()
{
    tstring     strGroupAlias;
    WCHAR       szName[UNLEN+1];
    DWORD       cchName = UNLEN;
    UINT        uiReturnValue = -1;


    uiReturnValue = GetProperty( _T("GROUPALIAS_ADMINISTRATORS"), strGroupAlias );
    if ( uiReturnValue ) return uiReturnValue;


    // If something is already defined then don't override it.
    if( strGroupAlias.empty() )
    {
        if( !LookupAliasFromRid( NULL, DOMAIN_ALIAS_RID_ADMINS, szName, &cchName) )
        {
            LogMessage(
                INSTALLMESSAGE_ERROR,
                NULL, 
                NULL,
                NULL,
                GetLastError(),
                _T("Setup was unable to determine the Administrators group name.")
            );
            return ERROR_INSTALL_FAILURE;
        }

        uiReturnValue = SetProperty( _T("GROUPALIAS_ADMINISTRATORS"), szName);
        if ( uiReturnValue ) return uiReturnValue;
    }


    return ERROR_SUCCESS;
}
示例#2
0
UINT initializeAfsAdminGroup(void) {
    PSID psidAdmin = NULL;
    SID_IDENTIFIER_AUTHORITY auth = SECURITY_NT_AUTHORITY;
    NET_API_STATUS status;
    LOCALGROUP_MEMBERS_INFO_0 *gmAdmins = NULL;
    DWORD dwNEntries, dwTEntries;
    WCHAR AdminGroupName[UNLEN+1];
    DWORD cchName = UNLEN;

    if (!LookupAliasFromRid( NULL, DOMAIN_ALIAS_RID_ADMINS, AdminGroupName, &cchName )) 
    {
        /* if we fail, we will try the English string "Administrators" */
        wcsncpy(AdminGroupName, L"Administrators", UNLEN+1);
        AdminGroupName[UNLEN] = 0;
    }

    status = NetLocalGroupGetMembers(NULL, AdminGroupName, 0, (LPBYTE *) &gmAdmins, MAX_PREFERRED_LENGTH, &dwNEntries, &dwTEntries, NULL);
    if(status)
        return status;

    status = NetLocalGroupAddMembers(NULL, AFSCLIENT_ADMIN_GROUPNAMEW, 0, (LPBYTE) gmAdmins, dwNEntries);

    NetApiBufferFree( gmAdmins );

    return status;
}