<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package GLPI::Agent::Task::Inventory::Generic::Remote_Mgmt::LiteManager;

use strict;
use warnings;

use parent 'GLPI::Agent::Task::Inventory::Module';

use GLPI::Agent::Tools;

sub isEnabled {
    return 0 unless OSNAME eq 'MSWin32';

    GLPI::Agent::Tools::Win32-&gt;use();

    my $key;
    first {
        $key = GLPI::Agent::Tools::Win32::getRegistryKey(
            path        =&gt; $_,
            # Important for remote inventory optimization
            required    =&gt; [ 'ID (read only)' ],
            maxdepth    =&gt; 1,
        ) &amp;&amp; $key &amp;&amp; keys(%{$key})
    } qw(
        HKEY_LOCAL_MACHINE/SYSTEM/LiteManager
        HKEY_LOCAL_MACHINE/SOFTWARE/LiteManager
    );
    return $key &amp;&amp; keys(%{$key});
}

sub doInventory {
    my (%params) = @_;

    my $inventory = $params{inventory};
    my $logger    = $params{logger};

    my $liteManagerID = _getID( logger =&gt; $logger );

    if ($liteManagerID) {
        $logger-&gt;debug('Found LiteManagerID : ' . $liteManagerID) if ($logger);

        $inventory-&gt;addEntry(
            section =&gt; 'REMOTE_MGMT',
            entry   =&gt; {
                ID   =&gt; $liteManagerID,
                TYPE =&gt; 'litemanager'
            }
        );
    } else {
        $logger-&gt;debug('LiteManagerID not found') if ($logger);
    }
}

sub _getID {
    my (%params) = @_;

    my $id;
    first {
        $id = _findID(
            path =&gt; $_,
            %params
        )
    } qw(
        HKEY_LOCAL_MACHINE/SYSTEM/LiteManager
        HKEY_LOCAL_MACHINE/SOFTWARE/LiteManager
    );

    return $id;
}

sub _findID {
    my (%params) = @_;

    GLPI::Agent::Tools::Win32-&gt;use();

    my $key = GLPI::Agent::Tools::Win32::getRegistryKey(
        %params,
        # Important for remote inventory optimization
        required    =&gt; [ 'ID (read only)' ],
    );

    return unless $key &amp;&amp; keys(%{$key});

    my $parameters;

    foreach my $sub (grep { m|/$| } keys(%{$key})) {
        next unless $key-&gt;{$sub}-&gt;{"Server/"};
        next unless $key-&gt;{$sub}-&gt;{"Server/"}-&gt;{"Parameters/"};
        $parameters = $key-&gt;{$sub}-&gt;{"Server/"}-&gt;{"Parameters/"};
        last;
    }

    return unless $parameters;

    return $parameters-&gt;{"/ID (read only)"};
}

1;
</pre></body></html>