Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 11 Jun 2010, 18:34
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Manually adding user to database; Can't login with user

I am trying to make a little script to manually add a new user to the vbulletin database. I understand how the password hashing works and have made a script that shows me what should be in the password field when I put in whats in the salt field, so I know the user im manually adding has the right password accoridng to it's salt. For some reason I still can't login to vbulletin with this user I manually added. I tried password reset on the user and afterwards logging in worked with the new password. I assumed some field in db I missed was preventing the original from logging so I compared the user's db info before and after password reset, and other than the password and the salt, I saw no difference. So I am really stumped on what could be preventing the login.

Like I said, I looked at the salt for a working user, and did the md5(md5(password) . salt) and got whats in the password field, then did the same for the manually added user whom I can't login with and got what the password field said for both, so I know thats not the problem.

I am using the code for adding the admin user in the install portion of the script as a template for manually adding this user. The only thing I am doing differently is the options field. I am not puting any of the useroption defaults like vbasset_enable, showsignatures because I don't really know how to insert that. However, the user still is getting a string of numbers in the 'options' field in the database, however it isnt changing after the password reset so I don't even see how that could be the problem.

I am totally stumped on this, please help.
Reply With Quote
  #2  
Old 11 Jun 2010, 18:57
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
If you want coding help, the best thing to do is to post your exact code, let us know exactly where you are adding it, and then post your template, and let us know where it is being added.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 11 Jun 2010, 19:00
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Ok, this is just on a php file not in an vbulletin file.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #4  
Old 11 Jun 2010, 19:06
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
In vb4, salt is 30 characters, not 3:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change that to 30.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 11 Jun 2010, 19:16
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Changed it. Didn't fix the problem. I put 3 because in vb when it makes the admin account in install it used 3. Either way, I have the same problem though.
Reply With Quote
  #6  
Old 11 Jun 2010, 19:19
NBZ4live NBZ4live is offline
 
Join Date: Jun 2010
Lightbulb

The best way to add new account to vBulletin is to use the vB_Datamanager_User.
Here is the code I use in my Integration.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Try include global.php to your script and then use this function to create the accounts.
Reply With Quote
  #7  
Old 11 Jun 2010, 19:50
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Worked beautifully! Thank you so much for sharing your code with me. I guess I was just taking the wrong approach to this by trying to force the db entry rather than work with the vb code.

I have one more problem, and this may be a dumb question. I want this code to not be in the /forum directory but in the root directory of my site. If I include the global.php file, it includes /includes/class_bootstrap.php. Since my original file is not in the same directory as the global.php, the address to class_bootstrap isn't correct for my original file and I get a cannot find file error. I looked in some of the vb files to see how they solved this problem, and I see that they use this format when in this situation:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Using this "DIR" does not work on my file outside of the forum directory, as I assumed. How can I do the same thing but with my file outside of the forum directory?
Reply With Quote
  #8  
Old 12 Jun 2010, 00:10
NBZ4live NBZ4live is offline
 
Join Date: Jun 2010
Use
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

before including global.php

Here is the description: chdir

after using the Datamanager to add the user you can change the directory back with
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #9  
Old 12 Jun 2010, 00:58
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Originally Posted by NBZ4live View Post
The best way to add new account to vBulletin is to use the vB_Datamanager_User.
Here is the code I use in my Integration.

Try include global.php to your script and then use this function to create the accounts.
My problem with that solution (and why I often opted for the manual solution whenever I needed to do something like this ) is that if a user is temporarily suspended from the forums they are blocked from any pages that include global.php. Obviously for this exact thing it's not an issue as they won't even be registered at this point. But more for things like PM creations, checking your user is logged in (checking sessions same way as vb does and updating last activity etc), and other similar things like that.

Or at least that's the result I got when I tested this a few years ago. And that was an unacceptable condition for our website. Banned for life members I would agree with. But we still wanted people that were suspended (for things like spamming etc ) to still be able to use the rest of our website. We saw the website and forums separate in that sense. Just seemed so strange to me that it forced it on you. Unless there's a way to stop that which I'm not aware of, or if they've changed how that works since I tested it a few years ago. I'd much prefer to use Vb's own functions/data managers as it's a bit messy doing things yourself.
Reply With Quote
  #10  
Old 12 Jun 2010, 04:38
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Well the script I'm trying to integrate with vb is not letting me include global.php. Every time I try I get some error that says ajax must be enabled. So I guess I'm going to have to stick with the manual route. That being said, I still don't know why my original code didn't work correctly. Consolegaming can you either tell me what is wrong with my code or give me a sample of how you are manually inserting users to vb database? I would be very appreciative.
Reply With Quote
  #11  
Old 12 Jun 2010, 11:43
consolegaming consolegaming is offline
 
Join Date: Jan 2007
I'm afraid we don't manually insert users at the moment. I do quite a few other things manually but that's not one of them. We had started to come up with a Registration script but at the time (a few years ago) it was just taking too much time to do trying to replicate the whole registration process of activation codes and then activating them. So we scrapped it and just linked diretcly to our registration script lol. And our login form just posts to the forum's page.
Reply With Quote
  #12  
Old 13 Jun 2010, 05:57
auctionguy auctionguy is offline
 
Join Date: Mar 2007
Ok I got it to work finally using the manual way. Then I tried it again and it didn't. I don't understand.. The variable holding the md5('actual password') is what it should be, however the hash of the salt plus hashed pass (md5(md5(actual pass) . salt) is not coming out to what it should be. Could apostrophe's in the salt be causing this?

Here is code for the password part. Note that the salt has already been generated. The data['password'] contains the correct password, I have checked. I have checked every step to what it should be up to the last where its going wrong.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

EDIT: I've ran a few tests and it appears that apostrophe's are the problem. Any user with an apostrophe in the salt doesn't work, any without apostrophe's works.

Last edited by auctionguy; 13 Jun 2010 at 06:07.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:49.

Layout Options | Width: Wide Color: