Announcement Announcement Module
No announcement yet.
Check existence of attribute in LDAP Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check existence of attribute in LDAP


    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
    To search for existence of an attribute, use a single * in your filter, e.g.:


    • #3
      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
        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.


        • #5
          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 : . 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.