MprAdminUserSetInfo (mpr)
Last changed: anonymous

.
Summary
Sets the dialin and callback privilege.

C# Signature:

  [DllImport("mprapi.dll", SetLastError = false)]
    static extern UInt32 MprAdminUserSetInfo(
        [MarshalAs(UnmanagedType.LPWStr)]  string serverName,
        [MarshalAs(UnmanagedType.LPWStr)]  string userName,
        UInt32 Level,
        ref RAS_1 buffer);

VB Signature:

Declare Function MprAdminUserSetInfo Lib "mpr.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

private const byte RASPRIV_NoCallback = 1;

private const byte RASPRIV_AdminSetCallback = 2;

private const byte RASPRIV_CallerSetCallback = 4;

private const byte RASPRIV_DialinPrivilege = 8;

private const byte RASPRIV_NoDialInPrivilege = 255 - RASPRIV_DialinPrivilege;

Tips & Tricks:

Please add some!

Sample Code:

    private bool setDialin()
    {
        bool hasError = false;

        try
        {
        RAS_1 rasUser = new RAS_1();
        UInt32 result = MprAdminUserGetInfo(serverName, userId, 1, ref rasUser);
        if (result != 0)
        {
            throw new Exception("MprAdminUserGetInfo failed with code " + result.ToString());
        }

        // enable/disable dial in
        if (dialInEnabled)
        {
            rasUser.bfPrivilege |= RASPRIV_DialinPrivilege;
        }
        else
        {
            rasUser.bfPrivilege &= RASPRIV_NoDialInPrivilege;
        }

        result = MprAdminUserSetInfo(serverName, userId, 1, ref rasUser);
        if (result != 0)
        {
            throw new Exception("MprAdminUserSetInfo failed with code " + result.ToString());
        }
        }
        catch (Exception ex)
        {
        hasError = true;
        errorDescription = "MgtLib, setDialin: Exception with userId=<" + userId + "> and enable=<" + dialInEnabled.ToString() + ">: " + ex.Message;
        }

        return hasError;
    }

Documentation