I’m not experienced in programming native code, so I thought I’d share this code snippet for others.  In order to enable / disable dial in permissions I thought that you could just set the value of the msNPAllowDialIn attribute.  But, as the documentation indicates, you should use the (native) RAS methods.  This is because the actual permissions is held is the userParameters attribute.  This attribute can hold information for multiple purposes, so directly editing it probably isn’t the best idea. So, if you directly set msNPAllowDialIn to true, the permission will not work; but setting it to false will disable the permission.

This took a good amount of research and a lot of testing, but below was my solution.  It uses a hard coded PDC value, but you may want to look into using MprAdminGetPDCServer to get the current PDC.  I wrapped the code in a .NET class to make it easier for those less familiar in native programming.

public class MsRapi
{
 
    public const byte RASPRIV_DialinPrivilege = 0x08;
 
    [StructLayout(LayoutKind.Sequential)]
    public struct RAS_USER_0
    {
        public byte bfPrivilege;
        public string phonenumber;
 
    }
 
    [System.Runtime.InteropServices.DllImportAttribute("mprapi.dll", EntryPoint = "MprAdminUserSetInfo")]
    public static extern uint MprAdminUserSetInfo([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpwsServerName, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpwsUserName, uint dwLevel, IntPtr lpbBuffer);
 
}

To call the method:

MsRapi.RAS_USER_0 user0 = new MsRapi.RAS_USER_0();
user0.bfPrivilege = MsRapi.RASPRIV_DialinPrivilege;
user0.phonenumber = null;
 
string server, user;
server = "PRIMARYDOMAINCONTROLLER";
user = "USERACCOUNT";
 
int len = Marshal.SizeOf(user0);
 
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(user0, ptr, false);
 
MsRapi.MprAdminUserSetInfo(server, user, 1, ptr);
 
Marshal.FreeHGlobal(ptr);

I was unable to get the MprAdminUserSetInfo to return an error when there was a problem (like entering a bad PDC), so you would definitely want to test before implementing.