Hi,
I'm developing a custom login module, where the user, after entering a one-time password, can create a new user. Can you guide me to how I can create a new user programmatically?
Thanks,
Jesper
Developer forum
E-mail notifications
Create new user in DW7
Jesper Troelsen
Posted on 11/07/2012 08:36:46
Replies
Morten Bengtson
Posted on 11/07/2012 08:57:32
You could start by upgrading to DW8 ;)
What version of DW7 are you using? 19.0.0.5, 19.2.9.5 or something in between?
What version of DW7 are you using? 19.0.0.5, 19.2.9.5 or something in between?
Jesper Troelsen
Posted on 11/07/2012 09:02:11
Ok, I will consider DW8 :-)
Currently I'm using 19.2.8.3..
Morten Bengtson
Posted on 11/07/2012 09:05:23
This post has been marked as an answer
Try this...
var user = new Dynamicweb.Modules.UserManagement.User("username"); user.Password = "test1234"; // or use Dynamicweb.Base.PasswordGenerate(string.Empty); user.Email = "test@example.org"; user.AddToGroup(255); user.Save();
Votes for this answer: 0
Jesper Troelsen
Posted on 31/07/2012 12:01:01
When I create a user this way it get written to the database fine. But when I open the user from Admin I get the following error:
Invalid object name 'EcomLanguages'.
Do I need to set something else?
Stack track:
[SqlException (0x80131904): Invalid object name 'EcomLanguages'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950522
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4856715
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1121
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +83
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +293
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
Dynamicweb.Database.getDataReader(String SQL, String Database, Int32 timeout) +484
Dynamicweb.eCommerce.International.LanguageCollection.Load(String SQL) +22
Dynamicweb.eCommerce.International.Language.get_CachedLanguages() +174
Dynamicweb.eCommerce.International.Language.getLanguages() +53
Dynamicweb.eCommerce.Common.Application.get_Languages() +85
Dynamicweb.eCommerce.Common.Application.get_DefaultLanguage() +22
Dynamicweb.Admin.UserManagement.EditUser.FillCurrency() +74
Dynamicweb.Admin.UserManagement.EditUser.FillControls() +1957
Dynamicweb.Admin.UserManagement.EditUser.Page_Load(Object sender, EventArgs e) +393
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Morten Snedker
Posted on 31/07/2012 12:09:26
Is that on you local Pc or an actual solution? If actual solution: which?
Regards /Snedker
Regards /Snedker
Jeppe Eriksson Agger
Posted on 31/07/2012 12:17:50
It seems that you database could be broken. This exception would indicate that you have installed eCommerce but have no table called EcomLanguages. If eCom is installed, this table is needed. If, however, no eCom is installed, there is something wrong with your Module table.
Please let me know if you do have eCommerce installed and whether you have the EcomLanguages table, or if the solution is Access based.
- Jeppe
Please let me know if you do have eCommerce installed and whether you have the EcomLanguages table, or if the solution is Access based.
- Jeppe
Jesper Troelsen
Posted on 31/07/2012 12:59:06
It is on a real solution: humira.dynamicweb.dk
And sorry, the error happens for all users - not just the one I created..
A replyfrom Jeppe Eriksson Agger seems to be missing.. The reply to his questions: We do not have an EcomLanguages table in the database - but I also cannot see that we should have eCommerce installed.
Jeppe Eriksson Agger
Posted on 31/07/2012 13:50:40
Editing a user in the Backend on DW7.2 (and earlier) requires this table to exist even though eCommerce is not installed. This has been fixed for DW8 (and newer). However this table should be part of your database no matter what. If it's missing then your database is not in a complete state. Was the solution migrated from Access to SQL Server at some point, or could someone have been dropping tables from it?
Jesper Troelsen
Posted on 31/07/2012 14:12:01
I don't know if it was migrated from Access to SQL. It is a rather old solution, so it might very well be the case. I of course cannot guarantee that no-one had dropped the table, but I think it sounds unlikely.
I have tried to create the table (from my dev environment), but I now the the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
Stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Dynamicweb.Admin.UserManagement.EditUser.FillCurrency() +77
Dynamicweb.Admin.UserManagement.EditUser.FillControls() +1957
Dynamicweb.Admin.UserManagement.EditUser.Page_Load(Object sender, EventArgs e) +393
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Jesper Troelsen
Posted on 31/07/2012 21:49:01
Could you please also tell me where I can see the ID of particular Goup?
Jesper Troelsen
Posted on 31/07/2012 22:01:31
I found out myself :-) Groups can be found in AccessUser where AccessUserType=2
You must be logged in to post in the forum