I am trying to get information from a built in report, and add it to a custom attribute. I need to get the IP address in the built in report "Dial-in and VPN settings" and add it to a custom attribute for each user.

I tried modifying this script to get there: https://www.adaxes.com/script-repository/update-boolean-attribute-with-password-self-service-enrollment-status-s680.htm

I think the main issues are:

  • The well known container path. I can't figure out the path for Reports > All Reports > Users > Dial-in and VPN Settings
  • my ADM_PSREPORTTYPE is also probably wrong
  • And at the very end, I try to get $userstaticIP from the "Dial-In and VPN settings" report which contains the info I need.

Here is the script:

$propertyName = "adm-CustomAttributeBinary1" # TODO: modify me

# Bind to the 'Dial-in and VPN settings' container
$DialInReportPath = $Context.GetWellKnownContainerPath("Report")
$DialIn = $Context.BindToObject($DialInReportPath)

# Get the Dial-in and VPN settings report
$reportIsBeingGenerated = $True
do
{
    try
    {
        $report = $DialIn.GetReport("ADM_PSSREPORTTYPE_DialinandVPNsettings")
    }
    catch [System.Runtime.InteropServices.COMException]
    {
        if ($_.Exception.ErrorCode -eq "-2147024875")
        {
            # Report is being generated. Wait 10 seconds
            Start-Sleep -Seconds 10
            continue
        }
        else
        {
            $reportIsBeingGenerated = $False
            $Context.LogMessage($_.Exception.Message, "Error")
            return
        }
    }

    if ($report.GenerateDate -lt [System.Datetime]::UtcNow.AddHours(-1))
    {
        $DialIn.ResetReportCache("ADM_PSSREPORTTYPE_DialinandVPNsettings")
    }
    else
    {
        $reportIsBeingGenerated = $False
    }
}
while ($reportIsBeingGenerated)

$records = $report.Records
for ($i = 0; $i -lt $records.Count; $i++)
{
    $record = $records.GetRecord($i)

    # Get user information
    $userPath = $NULL
    $userDisplayName = $NULL
    $userstaticIP = $NULL
    $userInfo = $record.GetUserInfo([ref]$userPath, [ref]$userDisplayName, [ref]$userstaticIP)

    # Update user
    $user = $Context.BindToObject($userPath)
    $user.Put($propertyName, $userstaticIP)
    $user.SetInfo()
}
by (380 points)

1 Answer

by (307k points)
0 votes

Hello,

Unfortunately, the approach you are using is overcomplicated and hardly usable. As an option, you can create a scheduled task configured for the User object type. For each user the task will execute a PowerShell script that will obtain values just like the report script and save them to Adaxes custom attributes. The following article should be helpful in writing the script: https://adaxes.com/sdk/ServerSideScripting.

by (380 points)
0

My issue is that the property I need, msRADIUSFramedIPAddress, is expressed as an integer and not a user friendly value when I add it to the web interface. So it will say something like "-1235678" instead of "156.111.111.111."

I am still trying to grasp Adaxes scripting, so I tried the below but got a System.Double error. Will the solution here help me? https://www.adaxes.com/questions/1134/attribute-type-conversion

$newproperty = "adm-CustomAttributeBinary1"

$dialinIP = "msRADIUSFramedIPAddress"
if ($NULL -ne $dialinIP)
    {
        $ipBytes = [System.BitConverter]::GetBytes($dialinIP)
        [System.Array]::Reverse($ipBytes)
    try
        {
            $value = $Context.TargetObject.Get($dialinIP)
        }
    catch
        {
            $value = None
        }

    $Context.TargetObject.Put($dialinIP, $value)
    $Context.TargetObject.SetInfo()

    # Get user information
    $userPath = $NULL
    $userDisplayName = $NULL
    $userInfo = $record.GetUserInfo([ref]$userPath, [ref]$userDisplayName)

    # Update user
    $user = $Context.BindToObject($userPath)
    $user.Put($newproperty, $dialinIP)
    $user.SetInfo()
by (307k points)
0

Hello,

The solution from the Q&A article you referenced will not work for the msRADIUSFramedIPAddress property as it is of the Integer type. Also, we are not sure why you are trying to save the IP address to a binary property. To be able to see it as is, a text attribute (e.g. CustomAttributeText1) should be used. You can try the below script.

function ConvertRADIUSIPAddress($RADIUSIPAddress)
{
    $bin=[convert]::ToString([int32]$RADIUSIPAddress,2).PadLeft(32,'0').ToCharArray()
    $A=[convert]::ToByte($bin[0..7] -join "",2)
    $B=[convert]::ToByte($bin[8..15] -join "",2)
    $C=[convert]::ToByte($bin[16..23] -join "",2)
    $D=[convert]::ToByte($bin[24..31] -join "",2)
    return $($A,$B,$C,$D -join ".")
}

$targetProperty = "msRADIUSFramedIPAddress" # TODO: modify me
$updatePropertyName

# Get property value
try
{
    $integerValue = $Context.TargetObject.Get($targetProperty)
}
catch
{
    $Context.LogMessage("Property $targetProperty is empty", "Warning")
    return
}

# Convert property value to IP address
$ipAddress = ConvertRADIUSIPAddress $integerValue

# Update the user
$Context.TargetObject.Put("adm-CustomAttributeText1", $ipAddress)
$Context.TargetObject.SetInfo()

Related questions

Hi, when I enable a license for Exchange Online for a user I get the following warning: Here are the current settings for creating a remote ... : InvalidOperation: (:) [], RuntimeException     + FullyQualifiedErrorId : PropertyAssignmentException

asked Nov 18, 2025 by Allister (90 points)
0 votes
1 answer

When tryin to add a new server to a current shared configuration, i get a "Failed to Connect to Service Configuration Server", Username or Password wrong. I checked the ... with domain\username and username@domain, both with the same error. Any ideas on that?

asked Oct 14, 2025 by roppiffm (170 points)
0 votes
1 answer

Recently we started getting this error in Adaxes Some fields couldn't be loaded. Failed to get the mailbox usage information. Failed to commit the change on object " ... are correct but the issue persists. This is occuring with Exchange Online only:

asked May 21, 2025 by curtisa (350 points)
0 votes
1 answer

When attempting to modify a shared mailbox that is in 365 but anchored in on premise AD, I am receiving the following error when trying to add a regular user to ... Builtin Administrators group anywhere, I'm not sure where Adaxes is picking this up from.

asked Jan 17, 2025 by curtisa (350 points)
0 votes
1 answer

Hi I've created a new adaxes configuration and limited access to do things based on the 'actions' section: only create, modify, delete contacts are available. Added myself to ... since updating to version 3.16.21408.0. How can I resolve this error? Thanks

asked Oct 4, 2023 by cheezoid (20 points)
0 votes
1 answer