Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

DNS DHCP IPAM

Reply

dhcp case insensitive name search with PAPI

Authority
Posts: 36
3683     0

How do I query a case insensitive search using PAPI?

 

Say, I'm searching for a DHCP object that has a name HELLO in Infoblox, now in my script I have the code snippet as below -

my @retrieved_objs = $session->get(
    object => "Infoblox:: DHCP::FixedAddr",
    name => $name,
    network_view => $networkview
);

 

This works only if I pass "hello" in caps in the arguments in command line. How do I make this search case insenstive?

 

Thank you.

Re: dhcp case insensitive name search with PAPI

Adviser
Posts: 136
3684     0

Hi,

 

You can use Regex. 

~	Regular expression search. Expressions are unanchored.

 

BR,

Vadim

Re: dhcp case insensitive name search with PAPI

Authority
Posts: 36
3684     0

I tried the following -

 

my @retrieved_objs = $session->get(
    object => "Infoblox:Smiley Very HappyHCP::FixedAddr",
    name ~=> /ABCD.hello.com/i,
    network_view => "Test"
);

 

It didn't work. Could you please help me out with the correct format?

Re: dhcp case insensitive name search with PAPI

Adviser
Posts: 69
3684     0

Hi, 

 

I dont think we can pull up the fixed addresses by using the regex that way.

I was able to meet the requirement but in a less efficient way. 

 

Code below:

 

 

#! /usr/bin/perl

use Infoblox;
use IO:Smiley Tonguerompt;

 

my $fa1 = prompt("Enter Fixed Address Name: ");
my $session = Infoblox:Smiley Frustratedession->new(
master => "10.192.32.240",
username => "admin",
password => "infoblox"
);
unless ($session) {
die("Construct session failed: ",
$session->status_code() . ":" . $session->status_detail());
}

my @fa = $session->search(
object => "Infoblox:: DHCP::FixedAddr",
network_view => "default"
);

my $counter = 0;
foreach (@fa) {
if ($fa[$counter]{name} =~ /$fa1/i) {
print $fa[$counter]{name}."\n";
}
$counter++
}

 

 

The script retrieves all fixed addresses in the default network view, then does a case insensitive comparison from the retrieved data to the user input and displays the results that match. 

 

I created two fixed addresses in NIOS with the names "HELLO.test.com" and "hello.test.com".

 

Please see below the output of the script.

 

work@srenjith ~/Dropbox/Scripting/Perl $ perl casetest.pl
Enter Fixed Address Name: HeLLo.test.com
HELLO.test.com
hello.test.com

 

work@srenjith ~/Dropbox/Scripting/Perl $ perl casetest.pl
Enter Fixed Address Name: HELLO.TEST.COM
HELLO.test.com
hello.test.com

 

work@srenjith ~/Dropbox/Scripting/Perl $ perl casetest.pl
Enter Fixed Address Name: hello.test.com
HELLO.test.com
hello.test.com

 

 

I don't know if this is feasible in your environment.But hope this helps. 

 

Regards, 

Sandeep

Re: dhcp case insensitive name search with PAPI

Authority
Posts: 36
3684     0

Thank you, Sandeep.

 

If the PAPI doesn't support regex, I guess yours is the best solution in this scenario.

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin