11 Replies Latest reply on Jun 10, 2013 11:36 AM by SantoshVaza

    how to suggest username in adf if it already exisist in database

    mm07
      i have a situation where i have requirement to suggest username if the username already exisit for example if i what to add user Jtomas if the user already exisit i can suggest user Jtomas007,Jtomas009 and so on am in jdeveloper 11.1.1.6.0

      Edited by: adf009 on 2013/04/26 10:10 AM
        • 1. Re: how to suggest username in adf if it already exisist in database
          John Stegeman
          What part of the requirement are you having trouble with? Is it generating a suggested name? If you can define an algorithm to come up with the suggestion, we can probably help you code it in SQL or PL/SQL.

          Is it some other part? If it is, you'd really need to give us the full use case and describe your page and how you expect it to work for us to be able to help you.

          John
          • 2. Re: how to suggest username in adf if it already exisist in database
            mm07
            ok at the moment i have this
            create or replace function RandomString(p_Characters varchar2, p_length number)
                return varchar2
                is
                  l_res varchar2(256);
                begin
                  select substr(listagg(substr(p_Characters, level, 1)) within group(order by dbms_random.value), 1, p_length)
                    into l_res
                    from dual
                  connect by level <= length(p_Characters);
                 return l_res;
               end;
            What part of the requirement are you having trouble with? Is it generating a suggested name? yes but i try to create the above function

            my page got inputtext where u entered username the field is been validated that if you enter duplicate you get the message to show that the username already exixist,what i what is when i entered the username which already exisist in database i must have the error massage which say the username already exisistt and at the same time suggest me the usename i can put
            the username field is
            <af:inputText value="#{bindings.Username.inputValue}" simple="true"
                                    required="#{bindings.Username.hints.mandatory}"
                                    columns="#{bindings.Username.hints.displayWidth}"
                                    maximumLength="#{bindings.Username.hints.precision}"
                                    shortDesc="#{bindings.Username.hints.tooltip}" id="it1"
                                    autoSubmit="true">
                        <f:validator binding="#{bindings.Username.validator}"/>
                      </af:inputText>
            Edited by: adf009 on 2013/04/26 10:35 AM
            • 4. Re: how to suggest username in adf if it already exisist in database
              John Stegeman
              The OP got a suggestion or two on the PL/SQL forum about a better suggestion algorithm (I saw the thread over there). Unfortunately, he/she hasn't responded on that thread either, so we don't know if it was helpful or not.
              • 5. Re: how to suggest username in adf if it already exisist in database
                Cvele_new_account
                I was thinking of principle - why would anyone offered a suggestion for the username? What's next? Suggestion for the password ?
                This is the first hole in the security system (if I understand correctly the question ...?)
                • 6. Re: how to suggest username in adf if it already exisist in database
                  John Stegeman
                  Well, there are plenty of online sites that will recommend a username for you.

                  If I go to GMail, for example, and try to create an account whose name matches my GMail account, I get a message saying "that username is already in use, here are some suggested usernames for you"

                  I don't see it as a security hole
                  • 7. Re: how to suggest username in adf if it already exisist in database
                    Cvele_new_account
                    Yes, agree, but this is wrong... by my opinion ;-)
                    regards,...
                    • 8. Re: how to suggest username in adf if it already exisist in database
                      John Stegeman
                      That's the great thing about opinions, everyone is free to have different ones :)
                      • 9. Re: how to suggest username in adf if it already exisist in database
                        dvohra21
                        http://www.oracle.com/technetwork/developer-tools/jdev/ajaxautosuggest-086726.html
                        • 10. Re: how to suggest username in adf if it already exisist in database
                          mm07
                          hi john thanks for helping was busy with other work igot your sql,so i must create a procedure and call it if the username already exsists
                          this is the field i what to have suggestname
                          <af:inputText simple="true"
                                                  required="#{bindings.Username.hints.mandatory}"
                                                  columns="20"
                                                  maximumLength="#{bindings.Username.hints.precision}"
                                                  shortDesc="#{bindings.Username.hints.tooltip}" id="it1"
                                                  value="#{bindings.Username.inputValue}" autoTab="true"
                                                  label="Username">
                                      <f:validator binding="#{bindings.Username.validator}"/>
                                    </af:inputText>
                          
                          this field is been validATED AS UNIQUE already and is working fine,must i implement this in entity level or view,but i must do this if the username only exisist
                          select suggested_name
                          from
                          (select :name || to_char(rownum, 'fm00000') suggested_name
                          from all_objects) x
                          where not exists (select null from uam_userdetails where username = x.suggested_name)
                          and rownum = 1
                          Edited by: adf009 on 2013/06/06 5:51 PM
                          • 11. Re: how to suggest username in adf if it already exisist in database
                            SantoshVaza

                            Hi,

                            i would be using following algo.

                            1. get username from user

                            2. check in db for it.

                            3. nw if it is available(i.e doesnot exists) then its good.

                            else

                            4. get user firstname, lastname, dob. i think that should be the topmost fields in form.

                            5. create some patterns. like first_name-last_name, firstnamelastname, firstname_dob etc..

                            6. create some 50-100 patterns

                            7. nw select only that usernames that doesnot exists by quering in db., and give those list to user.

                             

                            Better if you put all this logic in stored procedure level.

                             

                            Hope this helps..

                             

                            Thanks & Regards,

                            Santosh.