This project is read-only.

Documenting the Orchard User Object

Topics: Administration, General
Oct 14, 2012 at 12:11 PM

In response to Bertrand's oft-repeated that whining about holes in the documentation isn't valid unless the whiner accepts the responsibility to improve the product by annotating it, I'd like to undertake a bit of the task of updating the segment of the app as it relates to the user object.

I'm researching how to apply a default role to newly created users and/or how to create a commandline that can edit existing users by script. Editing and managing roles by the native UI is well documented. If you help me understand a script-based approach to this task I would happily digest and present documentation that can be added to existing pages.


Orchard.Users.Commands shows a basic commandline invocation:

       [CommandHelp("user create /UserName:<username> /Password:<password> /Email:<email>\r\n\t" + "Creates a new User")]


What steps are required to add a /UserRoles:<roles> switch to that switch?

Is it possible to create an 'Update User' commandline that would permit script-based role assignment?


Oct 14, 2012 at 7:39 PM

I hope I didn't phrase it in those words ;) Or I was in a very very bad mood that day.

It's perfectly valid to point out holes in documentation, I'm just trying to remind everyone that documentation is a great place to start contributing to the project, and to learn at the same time...

Anything should be possible with the command-line so yes, updating users looks like a good one. If you look at this UserCommands class, you'll see a number of properties with [OrchardSwitch] attributes. Adding a new one means adding the property, decorating it with the attribute, updating the command help message, and adding it to the OrchardSwitches attribute in the command. To read the value of the parameter from the command's code, just read the property. It should have been mapped automatically from the command line arguments.

All that's left to do is implement the thing.

Oct 15, 2012 at 11:52 AM

>>I hope I didn't phrase it in those words ;)

I tend to read between the lines fairly aggressively. ;) Thanks for the expansion. Just to drill at the issue of setting roles from the commandline - would this be an accurate statement:

Looking to add a role to a user on the CreateUser commandline won't work. It's not a matter of adding a role to the user, it's the inverse - the Orchard.Roles is the target and it has lists of users added it's various roles.

thanks again

Oct 15, 2012 at 4:31 PM

Yes. Maybe add the syntax for the command to add the role, or give the full couple of commands necessary to create the user and then put it in the role?