From: Eric S. J. <es...@ha...> - 2000-06-05 17:49:05
|
this is probably more of the perl problem than anything else but I'm trying to figure out how to pass a dynamic list of attributes to LDAP add. The base attribute list looks exactly like: $base_attributes = { objectclass => 'minimalRadiusPerson', ServiceType => '2', FramedProtocol => 'PPP', FramedMTU => '1500', AscendIdleLimit => '900' }; as the data source specifies additional attributes, I add them to the hash. Passing them on the other hand has been a bit of a problem. I'm missing something about perl references which will let me pass this reference to an anonymous hash in as an attrs argument. I've tried different forms but I'm not getting the right level of dereferencing. What I missing? ... $ldap_res = $mast_srv->add ($dn, attrs => $base_attributes ); die "unable to add entry $dn " if ($ldap_res->code); |
From: Jim H. <ha...@us...> - 2000-06-05 18:06:41
|
There are a variety of ways of doing this. My preference is @base_attributes = ( objectclass => 'minimalRadiusPerson', ServiceType => '2', FramedProtocol => 'PPP', FramedMTU => '1500', AscendIdleLimit => '900' ); $ldap_res = $mast_srv->add ($dn, attrs => \@base_attributes ); That is, using an array for the attribute list, then using a reference to that array for "attrs". Don't forget the \ before the reference. --Jim Harle US Naval Academy On Mon, 5 Jun 2000, Eric S. Johansson wrote: > this is probably more of the perl problem than anything else but I'm trying > to figure out how to pass a dynamic list of attributes to LDAP add. The > base attribute list looks exactly like: > > $base_attributes = { > objectclass => 'minimalRadiusPerson', > ServiceType => '2', > FramedProtocol => 'PPP', > FramedMTU => '1500', > AscendIdleLimit => '900' > }; > > as the data source specifies additional attributes, I add them to the hash. > Passing them on the other hand has been a bit of a problem. I'm missing > something about perl references which will let me pass this reference to an > anonymous hash in as an attrs argument. I've tried different forms but I'm > not getting the right level of dereferencing. What I missing? > ... > $ldap_res = $mast_srv->add ($dn, > attrs => $base_attributes > ); > die "unable to add entry $dn " if ($ldap_res->code); > > > > > > |
From: Eric S. J. <es...@ha...> - 2000-06-05 18:13:23
|
----- Original Message ----- From: "Jim Harle" <ha...@us...> To: "Eric S. Johansson" <es...@ha...> Cc: <per...@ma...> Sent: Monday, June 05, 2000 2:03 PM Subject: Re: passing dynamic attribute lists > There are a variety of ways of doing this. My preference is > @base_attributes = ( > objectclass => 'minimalRadiusPerson', > ServiceType => '2', > FramedProtocol => 'PPP', > FramedMTU => '1500', > AscendIdleLimit => '900' > ); > $ldap_res = $mast_srv->add ($dn, > attrs => \@base_attributes > ); > > That is, using an array for the attribute list, then using a reference to > that array for "attrs". Don't forget the \ before the reference. I'm confused. I thought that attrs => [] was a reference to a hash not a list. Converting attributes to a fixed array makes things a little more tricky... |
From: Mark W. <mew...@un...> - 2000-06-05 18:21:16
|
The Perl [] syntax means an array refeference. Thus you can also write it: $attrs = ['cn','mail','uid'] and you can pass it to the search() method without needing a \ in front of the variable. I'm not sure how this is trickier than before? If you already have a list of attributes as a hash, you can use keys or values to get the attributes back as an array. Mark On Mon, 5 Jun 2000, Eric S. Johansson wrote: > > ----- Original Message ----- > From: "Jim Harle" <ha...@us...> > To: "Eric S. Johansson" <es...@ha...> > Cc: <per...@ma...> > Sent: Monday, June 05, 2000 2:03 PM > Subject: Re: passing dynamic attribute lists > > > > There are a variety of ways of doing this. My preference is > > @base_attributes = ( > > objectclass => 'minimalRadiusPerson', > > ServiceType => '2', > > FramedProtocol => 'PPP', > > FramedMTU => '1500', > > AscendIdleLimit => '900' > > ); > > $ldap_res = $mast_srv->add ($dn, > > attrs => \@base_attributes > > ); > > > > That is, using an array for the attribute list, then using a reference to > > that array for "attrs". Don't forget the \ before the reference. > > I'm confused. I thought that attrs => [] was a reference to a hash not a > list. Converting attributes to a fixed array makes things a little more > tricky... > > > > > |
From: Mark W. <mew...@un...> - 2000-06-05 18:22:54
|
I didn't read this message before I made my earlier reply. If you replace your {} with [], your code should work as you expect without any other modifications. Mark On Mon, 5 Jun 2000, Eric S. Johansson wrote: > this is probably more of the perl problem than anything else but I'm trying > to figure out how to pass a dynamic list of attributes to LDAP add. The > base attribute list looks exactly like: > > $base_attributes = { > objectclass => 'minimalRadiusPerson', > ServiceType => '2', > FramedProtocol => 'PPP', > FramedMTU => '1500', > AscendIdleLimit => '900' > }; > > as the data source specifies additional attributes, I add them to the hash. > Passing them on the other hand has been a bit of a problem. I'm missing > something about perl references which will let me pass this reference to an > anonymous hash in as an attrs argument. I've tried different forms but I'm > not getting the right level of dereferencing. What I missing? > ... > $ldap_res = $mast_srv->add ($dn, > attrs => $base_attributes > ); > die "unable to add entry $dn " if ($ldap_res->code); > > > > > > |
From: Eric S. J. <es...@ha...> - 2000-06-05 18:33:09
|
----- Original Message ----- From: "Mark Wilcox" <mew...@un...> To: "Eric S. Johansson" <es...@ha...> Cc: <per...@ma...> Sent: Monday, June 05, 2000 2:20 PM Subject: Re: passing dynamic attribute lists > I didn't read this message before I made my earlier reply. > > If you replace your {} with [], your code should work as you expect > without any other modifications. thanks for the clarification. Unfortunately, my code is filled with hash related features so I will need to convert the hash array to a list just before I do the LDAP call. ugh... --- eric |
From: Pythagoras W. <py...@ec...> - 2000-06-05 19:22:33
|
On Mon, Jun 05, 2000 at 01:46:24PM -0400, Eric S. Johansson wrote: :$base_attributes = { ... : }; ... : $ldap_res = $mast_srv->add ($dn, : attrs => $base_attributes You should be able to change that line to: attrs => [%$base_attributes] to convert that hash reference to the expected array reference. -- Py (Amateur Radio: KF6WFP) -- 3.141592653589793238462643383... Pythagoras Watson -- "Live long and may all your kernels pop." === py...@cs... ==== http://www.ecst.csuchico.edu/~py/ === |