Results 1 to 5 of 5

Thread: Check existence of attribute in LDAP

  1. #1
    Join Date
    Mar 2009
    Posts
    4

    Default Check existence of attribute in LDAP

    Hi,

    I have created one attribute for passwordHistory, which is attached to all the new users attached but not to the already existing users. I want to write a script which would attach this attribute to all the existing users too. For that I want to check if passwordHistory attribute is even attached to the user or not. How would I do that?

  2. #2
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    To search for existence of an attribute, use a single * in your filter, e.g.:
    (passwordHistory=*)
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  3. #3
    Join Date
    Mar 2009
    Posts
    4

    Default

    Hi Rasky,

    What I meant was java code. The filter you are talking about is not very much familiar to me. I wanted to write a small utility which would find which user in the list (i have the user ids in hand) does not contain that attribute and i wanted to attach the attribute to it.

    Suppose from the users (user1, user2, user3), user1 and user3 have "passwordHistory" attribute attached to them in LDAP but for user2 it is not attached. How would I check for that and how would I attach the attribute to it? I do not want to manually add attribute to each already existing user as in my system there are more than 200 users.

  4. #4
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    You'll need to execute a search in your LDAP tree using the proposed search filter; actually, since what you seem to be aiming for are the users that do not have the attribute you would need to use the search filter (!(passwordHistory=*)). For each found entry you would then add the attribute using LdapTemplate#modifyAttributes()

    I would recommend the Spring LDAP reference documentation for further details. Note that you will still need to know about the basic LDAP concepts and structure, as well as the basics of Java LDAP/JNDI. Google will be your friend in finding more information about that.
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  5. #5
    Join Date
    Mar 2009
    Posts
    4

    Wink

    Hi Rasky,

    You are right that I am new to LDAP and do not have much basics. According to your suggestion I went through the manual regarding filters and just checked the Batch Operations which helped me to solve my problem in minutes. The link for manual is : http://directory.apache.org/studio/s...er_Guide.pd f . Batch Operations are listed at 3.6.

    Thanks a lot for your help. I solved the problem and now I don't have any issues in that.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •