Web Services API - User Account created, but unable to login

Web Services API - User Account created, but unable to login

by Gordon Brooks -
Number of replies: 16

Hello fellow Moodlers!

I'm working with my programmer and we've successfully used the web services API to create User Accounts in our 1.9.9 Moodle Instance, but after the user account is created the user can't login.  User can't login after they change they request password reset on the login page.


Any help on this would be great.  I imagine it is a setting somewhere, but we can't see where in the User Authentication or Security settings where this could be.

Thanks for your time and knowledge in advance.


Gordon

Average of ratings: -
In reply to Gordon Brooks

Re: Web Services API - User Account created, but unable to login

by Bill Antonia -

Hi Gordon,

Yes I've had this in the past, I think I solved this by setting the confirmed flag to 1 within the ???_user table directly in the database after I had created the accounts, not something which can be done via web services. Took me a while to work this one out at the time.

The other problem I had was to do with email confirmation of changing the password. As I was using LDAP authentication this was a pain so I unticked the "Email change confirmation" on the

Site Administration->Security->Site policies

page.

In Moodle 2.0 it seems the confirmed field defaults to 1 anyway, just looked at the users I've created this afternoon, all of which have not logged in yet. In my Moodle 1.9.7 the default value is 0. If you edit the table schema and change the default for the confirmed field to 1 then hopefully this would alleviate your problem for new users created via web services. You will still have to go back to the ones you have already created and set their confirmed field to 1 as well.

Hope this helps.

Regards

Bill

In reply to Bill Antonia

Re: Web Services API - User Account created, but unable to login

by Gordon Brooks -

Bill,

Thanks for your response on this.  I'm not sure how to access the DB because our instance is hosted.  I'm waiting to her back from our host and will let you know what happens.

Thanks again,

Gordon

In reply to Gordon Brooks

Re: Web Services API - User Account created, but unable to login

by Bill Antonia -

Hi Gordon.

Just had another look at this, you could possibly use the "Bulk user actions" in:

Site Administration->Users->Accounts->Bulk user actions

On the page there is a comboBox labelled "With selected users...", one entry is "Confirm". I have not used it myself but it looks as if it may do the job you require.

Regards

Bill

In reply to Bill Antonia

Re: Web Services API - User Account created, but unable to login

by Gordon Brooks -

Hi Bill,

Just tried that with no luck.  Another problem with it is that I need the enrolled participant to have immediate access. This option appears that I would need to login in and confirm once an enrollment came through (can't do this because the participant is making a payment on Paypal and needs access right away.)

I'm wondering if it might not be the issue with the DB like you mentioned previously.  I'm still waiting on access to the DB.


Would it be helpful to look at the script we are using?

I appreciate your help very much and hopefully we'll stumble upon the correct mix of options to provide the solution.

Gordon

In reply to Gordon Brooks

Re: Web Services API - User Account created, but unable to login

by Patrick Pollet -

>Would it be helpful to look at the script we are using?

 

Yes definitely, and also what version of the Web Service you are using (if it is OK Tech WS, version is given in script wspp/local/wspp/version.php).

 

Cheers.

In reply to Patrick Pollet

Re: Web Services API - User Account created, but unable to login

by Gordon Brooks -

Patrick,

Here is the script (attached as MS Word2007 so you can see formatting a little easier).  I'm not sure what version of WS are using.  How would I check that?  Remote-Learner is our provider and they turned it on.  I would imagine it is the original moodle WS.

Gordon

In reply to Gordon Brooks

Re: Web Services API - User Account created, but unable to login

by Ken DeVellis -

Hi Gordon,

I've had this problem in the past and managed to solve it by settting the mnethostid to a value of 3. Also, I noticed in your code that you set auth = "1". The auth column is a string type, so try setting it to a value of "manual".

Good luck,

Ken

Average of ratings: Useful (1)
In reply to Ken DeVellis

Re: Web Services API - User Account created, but unable to login

by Gordon Brooks -

Ken,

Thank you for the note.  I'll give it a try and let you know what happens.

Gordon

In reply to Ken DeVellis

Re: Web Services API - User Account created, but unable to login

by Patrick Pollet -

Hello,

I am baffled ... A script in ' Visual Basic' calling Moodle WS ... I did not know it was possible wink

Ken is right. With the 'old version' of OK Tech WS distribued by Remote Learner and documented in the book https://www.packtpub.com/moodle-1-9-extension-development/book you must

1) set auth value to 'manual'

2) set the value of a field named mnethostid to a proper value ( 3 is an example, you should look into Moodle's table mdl_config for the proper value (look for a record whose name is 'mnet_localhost_id' )).

3) you must also pay attention to the password. With Remote Learner 's WS it MUST be md5 encoded by you script .

 

In the long run you should consider replacing Remote Leaner's implementation with revision 1.8, available here https://github.com/patrickpollet/moodlews

Just unzip it in your Moodle's directory and change you client set up to call

http://yourmoodle/wspp/wsdl_pp.php instead of http://yourmoodle/Web Service/wsdl.php

Beside the fact that the  errors above are fixed ( don't set auth, mnethostid, lang, confirmed,deleted ...  and the server will adjust them to the correct default values, and the password will be md5 encoded on the server side using Moodle's internal hash, including the recently recommended 'password salt' security setting,  unless you send yourself a passwordmd5 attribute ), you will get much more operations and  Moodle's 2.0 compatibilty.

For example an operation named add_user () which is simpler to use that edit_users since it requires only an UserDatum record (with no action attribute set) and not anymore an array containing one UserDatum with action set to 'Add'. see http://moodle.org/mod/forum/post.php?reply=632104

Cheers.

In reply to Patrick Pollet

Re: Web Services API - User Account created, but unable to login

by gopi kishore -

hi

i am using php web services in .net application when i am using login function i am getting "SoapHeaderException was Unhandled by the user ".

please tell me how to solve this problem.

 

Thanks

In reply to gopi kishore

Re: Web Services API - User Account created, but unable to login

by Patrick Pollet -

@gopi,

Trap that exception in a try catch statement and give us the exception message.

Cheers

 

PLZ do not cross-post everywhere !!!

http://moodle.org/mod/forum/discuss.php?d=167007

In reply to Patrick Pollet

Re: Web Services API - User Account created, but unable to login

by gopi kishore -

hi patrick,

WS_errorregistersession.

This is the error message.

 

Thanks

In reply to gopi kishore

Re: Web Services API - User Account created, but unable to login

by gopi kishore -

Hi Patrick,

this is the exception:

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)   at mymoodle.MoodleWS.login(String username, String password) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\servicecall\5ce05a70\74e2b3d4\App_WebReferences.r4wf3mq1.0.cs:line 767   at _Default.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\vista19\My Documents\Visual Studio 2008\WebSites\servicecall\Default.aspx.vb:line 27

In reply to gopi kishore

Re: Web Services API - User Account created, but unable to login

by Patrick Pollet -

@gopi,

So you are likely aginst Moodle 2.0 and you forgot :

1) to copy the directory wspp/local/wspp to Moodle's local directory, thus the untransalted error message

2) to go to Administration / Notifications to install the required two tables in Moodle's database mdl_webservices_sessions and mdl_webservices_clients_allow

If you are in Moodle 1.9, there is a big problem with your Moodle's database since these two tables should be automatically created a the first call to login operation...

In reply to Patrick Pollet

Re: Web Services API - User Account created, but unable to login

by gopi kishore -

Thank you patrick

problem solved.