Alpha Video Training
Results 1 to 13 of 13

Thread: Admin to reset any user password WITHOUT "Old Password"

  1. #1
    Member
    Real Name
    Cornelius Laubscher
    Join Date
    Dec 2014
    Posts
    66

    Post Admin to reset any user password WITHOUT "Old Password"

    My dialog works well for an Admin to reset ANY user's password. The issue, is, Admin NEEDS to know the old password.

    I need the Admin to change the password for any user WITHOUT having to know the old password.

    Your help will be appreciated.

  2. #2
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    2,060

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    I saw that in the pre-release notes that this is a new feature coming down the pipe:
    http://downloads.alphasoftware.com/A...easenotes.html

    UX Component - Web Security Server-Side Action Scripts - The web security action scripts in a UX component now allow the password to be optional in the variable mapping even if the security setting require a password. The password is optional if the component can only edit an existing security record. The password mapping is required if the component can add a new user security record. A warning message will appear when the action script is saved if a password variable is not specified.

  3. #3
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Is your dialog built upon some specific Alpha dialog template? Can't you just remove the control that asks for the old password and then also remove any xbasic that demands that field entry be valid? Fundamentally, the Admin should not know the users password, ever.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  4. #4
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,171

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Instead of using the UX template "SecurityFramework-ChangePasswordAnyUser", start with the template "SecurityFramework-EditAccountForExistingUser" which doesn't require the old password.

  5. #5
    Member
    Real Name
    Cornelius Laubscher
    Join Date
    Dec 2014
    Posts
    66

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Quote Originally Posted by Steve Wood View Post
    Is your dialog built upon some specific Alpha dialog template? Can't you just remove the control that asks for the old password and then also remove any xbasic that demands that field entry be valid? Fundamentally, the Admin should not know the users password, ever.
    Hi Steve.

    Yes, its based on the template to reset ANY user password.

  6. #6
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    have you tried what jerry suggested in post #4?
    the way I have is
    a grid to show all the users and a button to edit on the row, click that button opens the dialog with that template and fills in the data and I change at will.
    no problems so far, except I have to wait few minutes.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  7. #7
    Member
    Real Name
    Cornelius Laubscher
    Join Date
    Dec 2014
    Posts
    66

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Ghandi,

    Yip I did. It does load all the details etc, BUT now I think instead of "updating" the record it actually tries to insert a new record for it gives me a duplicate username error.

  8. #8
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    of "updating" the record it actually tries to insert a new record
    I used the same edit security user framework, and it does not add new user just edits.
    please check again.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  9. #9
    Member
    Real Name
    Cornelius Laubscher
    Join Date
    Dec 2014
    Posts
    66

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Gandi,

    Just to recap;
    I created a normal updatable grid. I also created an UX from the template EditAccountForExistingUser. I changed the sql db connection properties as well as bound my user firstName, LastName, UserName and Mobile Number fields to the users table. The security framework fields remains unbound and I did not touch them.

    I created a button on the updatable grid [shows next to each user record]

    When I click the button, the UX loads and populates the user fields with data from my users table. To this stage everything seems to work fine.

    When I type a new password as well as confirm this password and submit the UX, the "username" field returns an error that the username already exists. This tells me that the UX tries to create a new user rather than updating the current user data.

    Is there perhaps a server side event that I need to change for I did no other changes except for those explained above.

    Thanks so much

  10. #10
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    http://screencast.com/t/MR1sdRbG8dv2
    take a look at this screencast. this is in my production machine and I cannot change lot of things.
    if you need more info I can show in my development machine later on and write a text file instructions if you need.
    I doubt that, you will figure it out.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  11. #11
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,171

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    When you create a UX to edit the current user, you must include the guid security field in the field mapping, normally as a hidden field. If this field has a value, it identifies the security record as an existing record. If the field doesn't exist or isn't mapped, the system thinks this is a new record.

    A username must always be unique. When the system validates the data on save, it gets the guid of any record with that username.

    • If no match is found, the username is allowed.
    • If the guid found is the same as the guid submitted for the current record (existing record and the username didn't change), it is allowed.
    • If the guid found does not match the current record guid, or no guid is supplied, this is not allowed as the system thinks it is a duplicate. This throws the error.

  12. #12
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,573

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    I've just set this up from scratch using Jerry's suggestion and it works as expected.

    This UX expects a security id (e.g. an email address) to be supplied in the onDialogInitialize event. To make this UX 100% standalone I made some modifications to it.

    To support multiple groups per user, replace the UserRoles radio control with a checkbox control. The radio control allows a user to belong to one group. The checkbox control allows multiple groups per user. However, you will need to provide code in the afterDialogValidate event to save the multiple selected groups for the user. I have not put in this code.

    Add a dropdown control to your UX (e.g. ddUsers). It's data source will come from the websecurityregisteredusers table. The value selected will be the Username. Now you can select a User to work on. In the onChange event for this control fire off an Ajax Callback... call the XBasic function something like getUserInfo, and create that XBasic function.

    The first line of this function will be...

    Code:
    dim id as c = e.dataSubmitted.ddUsers

    And this is the big one... in the onDialogInitialize Server-side event... you have to make some changes.

    1. Comment out the "Simulate a User" section.
    2. Leave the UserRoles stuff in place
    3. Put your cursor on the LoadUser line, click Action Scripting and then Convert to XBasic
    4. Copy this XBasic code into your getUserInfo XBasic function.
    5. Do the same for the LoadSecurity Action Scripting
    6. The LoadSecurity XBasic code must follow the LoadUser XBasic Code
    7. Now delete all the XBasic code created for LoadUser and LoadSecurity from the onDialogInitialize event. Only delete the code generated for those 2 Action Scripting items
    8. In the Ajax Callback, at the end of the generated code for LoadUser, add one line of code...

    Code:
    getUserInfo = e.javascript
    onDialogInitialize returns all the generated javascript code from LoadUser in e.javascript, but we're not running this code from onDialogInitialize. In our Ajax Callback we need to return the generated javascript to the Callback name instead.

    9. The XBasic code generated from LoadSecurity includes this line... a5ws_GetUsersWithDialog(e , rtc). This function assigns our User info (password etc.) to e.control. You can use e.control in onDialogInitialize to set default values for controls when a UX is loaded. But, we're not using onDialogInitialize, and so we need to change a few things. This code is added after a5ws_GetUsersWithDialog(e , rtc)

    Code:
    dim pVar as c
    dim pVarCnt as n
    dim pVarArray[0] as c
    pVar = properties_enum(e.control)
    pVarArray.initialize(pVar)
    pVarCnt = *count(pVar)
    
    dim e._set as p
    for i = 1 to pVarCnt
    	eval("e._set." + pVarArray[i] + ".value") = eval("e.control." + pVarArray[i])
    next i
    This code gets the data we need from e.control and creates the required e._set.<controlName>.value variable values. e._set assigns values to controls.

    So... when this UX is first run, it's empty. You select a user name from the dropdown list and the generated code gets values from websecurityregsiteredusers, websecurityusers, and websecuritygroups. The guid is one of the items retrieved and placed into a hidden control. You can make your changes to the password and save.

    I think this is a really good example of one of the many strengths of Alpha. It's open. If one of the supplied features doesn't do exactly what you want, you can easily create the code for that feature and modify it to suit your needs. Attached is the UX I modified as well as a short video of it's use.

    http://www.youtube.com/watch?v=b3ZtkQJ_uhI
    Attached Files Attached Files

  13. #13
    Member
    Real Name
    Iwashokun Opeoluwa
    Join Date
    Jul 2014
    Posts
    3

    Default Re: Admin to reset any user password WITHOUT "Old Password"

    Thanks Gandhi! stopped by here while searching for a resolve to same problem and your solution worked for me just fine. The screencast was indeed very useful. We should note to copy and paste the session variable settings specifies in the "override settings" property for the Users list grid. I noticed that I got some error when I tried to type it in even though it was correctly typed. SIMPLY COPY & PASTE, don't bother to type by yourself

Similar Threads

  1. Reset User Password
    By iRadiate in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 04-18-2012, 04:35 PM
  2. "Login Information Incorrect" in change Password Dialog
    By Locke in forum Application Server Version 9 - Web/Browser Applications
    Replies: 5
    Last Post: 06-21-2011, 02:25 PM
  3. Database User Account Password Reset
    By PopeDavid in forum Alpha Five Version 10 - Desktop Applications
    Replies: 1
    Last Post: 05-05-2011, 10:39 AM
  4. Login component fails on "Change Password"
    By Richard Veronneau in forum Application Server Version 9 - Web/Browser Applications
    Replies: 2
    Last Post: 02-13-2010, 11:50 PM
  5. Email for "lost password" not sending
    By Bill Parker in forum Application Server Version 8
    Replies: 2
    Last Post: 08-17-2007, 02:19 PM

Bookmarks

Posting Permissions

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