I cannot list multiple values for the same attribute

--00504502e1b31c762a04aa3cd03d
Content-Type: text/plain; charset=ISO-8859-1

Hi everyone,

I am new to perl-ldap and like it very much, however I have a problem I
cannot solve by myself (or using google).

I have some attributes with multiple values in the same entry, such as:

description: abc
description: def
description: ghi
....

I perform a search using a base & filter, then try to list all attributes
and their values in a foreach loop:

foreach my $entry ($searchResults->entries) {
    foreach my $attr ($entry->attributes) {
         for ($attr) {  if    (/^description$/) { printf ("%s -> %s \n",
$attr, $entry->get_value($attr) ); }
    }
}

the reason I am using for ($attr) is that I have several checks in the loop,
which I omit here for readability.

Now the problem: I noticed that $entry->attributes lists each attribute only
once! Therefore, I can only print a single value, which happens to be on the
top of the list (only "abc" in the above example).

Is there any other way to accomplish what I am trying to do? any help will
be greatly appreciate since I am stuck at this point :(

Thanks so much!
-Mehmet

--00504502e1b31c762a04aa3cd03d--
0
mbelgin (2)
8/11/2011 3:54:03 PM
perl.ldap 1268 articles. 0 followers. Follow

3 Replies
1723 Views

Similar Articles

[PageSpeed] 22

Mehmet wrote on 08/11/2011 10:54 AM:
> Hi everyone,
> 
> I am new to perl-ldap and like it very much, however I have a problem I
> cannot solve by myself (or using google).
> 
> I have some attributes with multiple values in the same entry, such as:
> 
> description: abc
> description: def
> description: ghi
> ...
> 
> I perform a search using a base & filter, then try to list all attributes
> and their values in a foreach loop:
> 
> foreach my $entry ($searchResults->entries) {
>     foreach my $attr ($entry->attributes) {
>          for ($attr) {  if    (/^description$/) { printf ("%s -> %s \n",
> $attr, $entry->get_value($attr) ); }
>     }
> }
> 
> the reason I am using for ($attr) is that I have several checks in the loop,
> which I omit here for readability.
> 
> Now the problem: I noticed that $entry->attributes lists each attribute only
> once! Therefore, I can only print a single value, which happens to be on the
> top of the list (only "abc" in the above example).
> 

You probably want instead something like:

 for my $entry ($searchResults->entries) {
     for my $attr ($entry->attributes) {
         if ($attr eq 'description') {
             printf("%s -> %s\n", $attr,
               join(", ", $entry->get_value($attr))
             );
         }
      }
  }




-- 
Peter Karman  .  http://peknet.com/  .  peter@peknet.com
0
peter
8/11/2011 4:42:52 PM
--00504502e1b321d18c04aa3dcd95
Content-Type: text/plain; charset=ISO-8859-1

Peter,

Thanks so much for your super-fast reply, which made me realize that
entry->get_value($attr)
returns a list which can be iterated :)

This definitely did the trick.

-Mehmet



On Thu, Aug 11, 2011 at 12:42 PM, Peter Karman <peter@peknet.com> wrote:

> Mehmet wrote on 08/11/2011 10:54 AM:
> > Hi everyone,
> >
> > I am new to perl-ldap and like it very much, however I have a problem I
> > cannot solve by myself (or using google).
> >
> > I have some attributes with multiple values in the same entry, such as:
> >
> > description: abc
> > description: def
> > description: ghi
> > ...
> >
> > I perform a search using a base & filter, then try to list all attributes
> > and their values in a foreach loop:
> >
> > foreach my $entry ($searchResults->entries) {
> >     foreach my $attr ($entry->attributes) {
> >          for ($attr) {  if    (/^description$/) { printf ("%s -> %s \n",
> > $attr, $entry->get_value($attr) ); }
> >     }
> > }
> >
> > the reason I am using for ($attr) is that I have several checks in the
> loop,
> > which I omit here for readability.
> >
> > Now the problem: I noticed that $entry->attributes lists each attribute
> only
> > once! Therefore, I can only print a single value, which happens to be on
> the
> > top of the list (only "abc" in the above example).
> >
>
> You probably want instead something like:
>
>  for my $entry ($searchResults->entries) {
>     for my $attr ($entry->attributes) {
>         if ($attr eq 'description') {
>              printf("%s -> %s\n", $attr,
>                join(", ", $entry->get_value($attr))
>             );
>         }
>      }
>  }
>
>
>
>
> --
> Peter Karman  .  http://peknet.com/  .  peter@peknet.com
>



-- 
=========================================
Mehmet Belgin, Ph.D. (mehmet.belgin@oit.gatech.edu)
Scientific Computing Consultant | OIT - Academic and Research Technologies
Georgia Institute of Technology
258 Fourth Street, Rich Building, Room 326
Atlanta, GA  30332-0700
Office: (404) 385-0665

--00504502e1b321d18c04aa3dcd95--
0
mbelgin
8/11/2011 5:04:48 PM
On 11 Aug 2011, at 18:04, Mehmet wrote:

> Peter,
> 
> Thanks so much for your super-fast reply, which made me realize that
> entry->get_value($attr)
> returns a list which can be iterated :)

When you call it in an array context it will return all the values, otherwise it will just return a single (ie scalar) value.

Cheers,

Chris
0
chrisridd
8/11/2011 5:58:59 PM
Reply:

Similar Artilces:

LDAP attribute Map / LIst / extend the LDAP attributes
we are use ladp on netware 65, is there a list of the LDAP attributes avaliable that are used for eDirectory 8.7? is it possible to create a ldap attribute that contains more that one edirectory attribute content and extend it with a static variable? any ideas HELGE -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Most eDirectory attributes are available natively by their name (minus spaces and special characters). For example fullname works to retrieve the 'Full Name' and givenname works for 'Given Name' and sasloginconfiguration works for 'SAS:...

add values to multiple-valued attribute error
try add multiple values to a mulitple-valued attribute (that can be done with a GUI / LDIF).However, use following code, I get error when insert multiple values for Properties("mgrpRFC822MailMember") (but it works with only one entry)Any help is very welcome.Thx Dim de1 = New DirectoryEntry("LDAP://" & ldapServerName & _            "/ou=MailGroup,dc=pcihl,dc=com", "cn=Manager,dc=pcihl,dc=com", "secret", AuthenticationTypes.ServerBind)            Dim newLstEntry As Direct...

Using specific values from multi-valued attributes via LDAP?
I understand how to inject LDAP attribute data in to the authentication process via the form fill, but is there a way to select a specific value from a multivalued attribute? Say for example that I have an attribute called "myPasswords" that has multiple string values specifying a URL and a stored password. I'd need to be able to search for the value needed for the URL I'm authenticating to, then parse out the password section of that string and inject it in to the "password" box in the form. Possible? Not possible? ---------------------------------...

Multi-valued attribute to single attribute conversion
Afternoon Everyone! I have been trying to use the default rule in the AD driver to strip multi-valued attributes but for a modify operation but without any luck. I made a copy and put it in the Command Transformation. Would someone please give me asome pinters. I keep getting LDap Error 21, Invalid syntax. Error in attribute conversion operation. Here is the rule I am attempting using: <rule> <description>Convert multi-valued Telephone to single value</description> <conditions> <and> <if-operation op="equal">modify<...

LDAP Attribute Values
Hi everyone,Is it possible to have dynamic/virtual attribute values for the LDAP owner attribute.  For example, if I have an owner attribute value set for an OU (organizational unit), can all users in that OU have that same owner attribute value dynamically assigned to them?Thanks. I am not sure what you mean.  Are you asking is there an AD supported way to infer that objects in an OU belong to the same owner of the OU?  Not really is the answer.  There are things like security ownership and things like 'managedBy' attribute that can show the 'owner' of an...

Multiple attribute value
C#, web form, VS 2005.  Thank you in advance for reading/helping.Working with XML returned from a web service,  have some nodes that have the same name but different attribute values. Ex.<ReceivedRecords pk=""/><ReceivedRecords pk="1234.56"/><ReceivedRecords pk="789.00"/>I'm setting the value of the XML to a text box using xPath...here is the code://Grab value of returned XML at this location.XmlNodeList xmn30 = mydoc.SelectNodes("/Envelope/Body/Response/Contract/ReceivedRecords/@pk");//Output the results to a text boxtxtReceivedRecords.Text = (xmn30[0].InnerText)...

Mutli-valued attribute to multi-valued attribute
We want to synchronize a multi-valued attribute (created by our own) to a multi-valued attribute in the other edirectory store. But when we are adding attributes we only have the changed values. The previous one is lost. When deleting one value in the Identity Vault then it removes the attribute from the object. Any ideas ? > We want to synchronize a multi-valued attribute (created by our own) to a > multi-valued attribute in the other edirectory store. But when we are > adding attributes we only have the changed values. The previous one is > lost. When deleting ...

List value attribute
 We have Range Attribute where we can specify the minimum and maximum value for a column is their a attribute or method by which i can specify a list of  valid values like (15,30,45,60)  Hi There, You can use reqularexpressionvalidator to validate the requirement. and maybe require field validator to ensure text is not empty <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="This is required!" ControlToValidate=&quo...

Insert multiple values(multiple columns) based on single dropdown list selection.
What I would like to accomplish:  I have a dropdown list that is an entityref(populated by values from PK in separate table). When user makes selection in dropdown list, then clicks “Insert”, I would like the selected value to be inserted into the applicable FK column, but also would like to have a value equal to the integer selected, multiplied by 50, inserted into another column of the same table. Example with user selecting “2” in the dropdown list, inserting into Table b:table a: Column: Numbers(PK) (1, 2, 4, 8) Table b: Processors(FK) Inserted: “2”Table b: Factor Inserted: ...

One attribute value to two attributes/ values in eDir
Collective, I have a very interesting issue. I have the need to break one attribute that is in AD (ADval1) to two attributes in eDir (attrval1 and attrval2) . Basically what I want to do is take ADval1 and break that data into the two other attributes, attrval1 and attrval2. The attribute in AD looks like this: AD attribute value data 1 | value data 2 In eDir it looks like this: eDir attribute 1 vlaue data 1 eDir attribute 2 value data 2 I don't know if that's clear, when it was explained to me it was a white board. Has anyone tried this or have any id...

Adding an attribute with multiple values.
Hi, It maybe a simple question. But I'm having some troubles with it. I'm using Net::LDAP::Entry and I'm trying to add an attribute with multiple values. Unfortunately, until now it didn't work out. A simple example: attr: value1 attr: value2 Just calling entry's add method multiple times does not worked out. Replace method didn't work out ether. Maybe I'm doing something wrong. Could someone give me an better idea or exemple on how to solve this problem? Thanks in advance, -- Relho de Couro On 11/11/04 8:15 pm, Relho de Couro <r...

How to replace multiple values of an attribute
Hi, I spent my whole afternoon searching for a solution for replacing all values of an attrbute by an array. So what i got is basicly an reference $values to an array of my new values. I could iterate through the array using foreach my $value (@$values) {...} The code that works is: my $mesg1=$backendConn->modify($dn, replace => [$attr, ["Hello", "Test"]] ); But i need to be more flexible and tried today a lot of variations of... my $mesg1=$backendConn->modify($d...

Returning Multiple Value Attributes
--LTeJQqWS0MN7I/qa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi List, I am using Net::LDAP and i am trying to return an attribute in a d= n that has multiple values. When I do the search and use $entry->get_value(= $attr ) it only returns the one value. Is there a way returning multiple a= ttribute values? Many thanks --=20 slr, ISP Systems Specialist Telkom Internet #qmail-ldap @ irc.freenode.net This message has been made from 100% recycled bits. ----BEGIN GEEK CODE BLOCK----- Version: 3.12...

Dropdown list with multiple values
Hi all, I'm retrieving two record fields from a table. Is it possible to bind both the values side by side to drop down list. Eg: Select empid,empname from emp. The values retrieved should be in a single dropdown list. I have seen this in Visual Foxpro. We can iniatialize a SQL query to Rowsource property of the dropdown list.  Thanks.Ali you can set one field as the key field, and the other as display.  You can also concatenate the key field into the display so that its only one column but contains id + " " + name fields. and the key field would be id (and would be hidde...

Web resources about - I cannot list multiple values for the same attribute - perl.ldap

Attribute - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Template:Attributes of God - Wikipedia, the free encyclopedia
Language: English Română Home Random Template:Attributes of God Part of a series on the Attributes of God Aseity Eternity Graciousness Holiness ...

Six Attributes Of The Perfect Facebook Page Administrator
So, here’s the thing: In many ways, hiring a Facebook page administrator is akin to hiring a poster child for your brand. This trusted manager ...

PANDA: Pose Aligned Networks for Deep Attribute Modeling - Facebook
We propose a method for inferring human attributes (such as gender, hair style, clothes style, expression, action) from images of people under ...

Facebook announces data partnerships to help advertisers target users by offline purchases and attributes ...
... will anonymously match data from consumer loyalty programs with user profiles in order to target ads by offline purchase habits and other attributes. ...

New Study Attributes Rapid Ageing Mainly To Environment Factors
New study explains why some people age faster than others.

Should I use the nofollow attribute on internal links? - YouTube
Regarding "nofollow" on internal links: Does it hurt? Does it help? I read different comments from Matt on this matter over time. What's the ...

Justin Trudeau attributes abortion stance to father's example
Liberal Leader Justin Trudeau says he is following an example set by his famous father when it comes to his position on election candidates and ...

Obama attributes western U.S. wildfires to climate change
... that has burned nearly 400 square miles in the north-central part of Washington state, along with blazes in other Western areas, can be attributed ...

Fifty Shades Of Grey Baby Births: Windsor Hospital Sees Spike In Births, Attribute Book
A significant spike in baby births at a hospital in Windsor, Ontario, has been attributed to the book Fifty Shades of Grey, which has become ...

Resources last updated: 1/4/2016 9:23:53 PM