How do I add field values to the `drush user-create` command? - drupal

I have been Googling this, read the drush documentation and searched StackOverflow, but I can't find an answer to this question.
I currently use drush user-create someone#example.com --password="somepassword" to create a user.
Then there are drush commands to add a role, block the user, etc. But nothing on adding/updating fields.
Does someone know how to set a custom user field to a created user, or immediately create a user with field values (for Drupal 7 that is)?
I need to do it without answering commandline questions.

You need a custom Drush command which accepts the arguments like UID and field values.
https://www.chapterthree.com/blog/how-to-create-custom-drush-commands
https://drupalize.me/videos/passing-arguments-drush-commands?p=1134
All commands in user: (user)
user-add-role (urol) Add a role to the specified user accounts.
user-block (ublk) Block the specified user(s).
user-cancel (ucan) Cancel a user account with the specified name.
user-create (ucrt) Create a user account with the specified name.
user-information Print information about the specified user(s).
(uinf)
user-login (uli) Display a one time login link for the given user account (defaults to uid 1).
user-password (upwd) (Re)Set the password for the user account with the specified name.
user-remove-role Remove a role from the specified user accounts.
(urrol)
user-unblock (uublk) Unblock the specified user(s).

Related

Sonatype Nexus: "invalid authentication ticket" on password change

I'm trying to change the admin password. I get this error:
invalid authentication ticket
It's a known issue: https://issues.sonatype.org/browse/NEXUS-10252
You need just to change your password within 15 seconds after entering current password.
I have a hack(ethical) and hence alternate but longer way to do this :-)
Steps:-
Create a new admin user(previously logged in using admin default credentials) - different user name, etc, etc
Now login using new(admin) user that you created in step 1.
Delete the previous admin user (the default one)
Again create a new admin user using new credentials
Login using admin user that you just created, and problemo solved :-)
It looked like i was changing the password and something else at the same time. I had to save the profile and then proceed with the password change.

Rename a Plone user account

Is it possible to rename the id of a Plone user?
Sometimes people have good reasons to change their user name, e.g. because of marriage. In the profile the name information can be changed easily, but the user id is written in some places, and the user name (which might not match the current name of the person anymore) can irritate group members.
I found this basic information about member manipulation, but there is nothing said about whether or not this would be at all supported.
The user manager plugin stores 3 attributes, the User ID, the login name and the password.
login name and password can be changed, the User ID is immutable.
The Login ID is only for internal usage, in your case you can go to ZMI -> acl_users > source_users > {SELECT USER} and change the login name.
You need to do it thru the ZMI, afaik there's no Plone UI for this purpose.
Update
According to the discussion I guess the wish of renaming a plone user should solve a problem I also know very well.
Example use-cases:
An employment gets replaced by another one.
Marriage, different userid for example als in AD/LDAP environment.
The userid is commonly used, like windows auth name, or similiar and thus needs to be changed.
This is how I usually solve this problem:
Create new user with the new ID
Copy all local roles from the old to the new user (Code example)
Remove all permission of the old user (Code Example)
Copy group membership (I got no script for this purpose since Plone has a good group membership form).
Change Ownershipt with plone.app.changeownership (This includes the Creators field).
The linked code is a package we usually install to solve exact the mentioned problems. If Plone would have a feature "Rename UserID" it would be likely that it would proceed those 4 steps.

drupal how to allow logged in user to edit specific content node?

I have a Drupal 7 site with single SSO via the LDAP module, which allows us to run the site as n Intranet and users that hit the site with IE will get automatically authenticated using their active directory credentials.
I have a personnel directory content type that holds a list of all of our employees and some of their stats (photo, email, phone number, etc.).
The problem I want to allow the logged in user to be able to edit the node in the personnel directory page that represents them, but because there is no relation between the logged in user and the nodes under the personnel directory content type I am not sure how to go about allowing users to edit their own entries?
The personnel directory page is automatically populated/updated via feeds (it looks at our AD, and pulls down users and updates them if it detects updates in AD meta data).
Somehow I need to tie the logged in user to the specific node, any idea how I could automate this as there are over 300+ nodes/users.
Ultimately, I'd like to have a "edit personnel bio" link that they can link, that will link based on their [current logged in user ID] it will allow them to edit the correct node in the [personnel directory] content type.
I hope this was clear enough to point me to some direction.
Thank you.
basically you want to create a user "role". Then in your permissions page (the one with 1000 checkboxes) you can add edit access to your "personnel bio" content type (or fields) for just that user role.
Then in your template you provide the user a link to the same page with /edit in the url.
Make sure the user has permissions to edit the node of that type. Upon creation of the node via feeds, create a rule (use the Rules module https://drupal.org/project/RULES) to change the creator of the node to that user's uid.
Add another field in the user's account to match their AD username to tie them together. To do this, create a module as seen at https://drupal.stackexchange.com/questions/8253/how-to-add-extra-fields-to-user-profile

Drupal trial account development

I am creating a website where you can create an account with your name and email. When this is done, you get a 30 day trial. From this point, you can 'upgrade' your account by supplying more information.
When you do not update your information after 30 days, your account is suspended.
Can anyone give me some tips how to do this ?
So:
- Create profile with email and name (easy), indicator is stored in db that you are trial user.
- When you log in, you can extend your profile with extra information. indicator that you are full user.
You can always write your own module to do it, but my recommendation is using the Rules module, and using several user roles.
Any new user gets a "trial" role he registers.
Create the needed fields in the user profile
Create a rule which will change the user's role in case the field is filled (rule triggeres whenever user profile is updated).
Create a rule with cron that executes once a day, to suspend user account, and probably to send him a notification before doing so.

How to set the Principal in an ASP.Net app

I am writing a web app for a client. Users will have a one-time key that they will use to initially identify themselves to the app. Once the app verifies that the key is valid it will take them to a page where they can create a normal account to use for all subsequent logins. The create-account page should only be accessible after entering the key and shouldn't be accessible otherwise. I.e, it shouldn't be accessible to users logged in with a normal account.
This is asp.net 3.0 using a custom membership provider.
My plan is to create a temporary account based on the key and authenticate the user with that account. This allows them access to the create-user page (which is protected with a location tag ) where they can create the formal account. I then authenticate them with their new account and delete the temporary account.
The flow is: the user goes to a page where they enter the key. If the key is valid I create the temporary account, call FormsAuthentication.SetAuthCookie, and redirect to the create-account page. This all works, although it seems a little complicated.
The problem is that the create-user page is available to any authenticated user; I only want it available during the time between entering the key and creating the formal account. So I thought I'd create a special role for the temporary account and make the create-user page accessible only to that role and none other. I created my own Principal object with a special role and tried setting it when I authenticate the temporary account but I can't get that to work.
I'm really hoping I don't have to write a custom role provider just to do this.
How can I make this work? There's gotta be a simpler way!
Why not simply create the real account when they enter the key. Assign it some random name and then let them change the name and other details. Then you don't need the create user page, just the enter key page and an account details editing page. If you're concerned about getting the account details filled in, you could set it up (perhaps via code on a MasterPage) so that incomplete accounts always get redirected to the edit details page until the details are entered.
Or, you could have them enter the required details in addition to the key code on the enter key page and simply use those details when creating the account.
My advice would be to avoid the use of temporary accounts when validating the user. Instead, generate your own logic for validating the sign-up key. Then, at the head of the page, you can check whether the user is an authenticated user (SetAuthCookie has been called) and jump to a different page if this is true.
You may even be able to change the page access to forbid this page to authenticated users (I know you can disable accounts for unauthenticated users but I'm not sure if you can go the other direction).
The key, though, is to avoid relying on the membership provider when, in fact, the user is not yet a member!
Assign an "incomplete" role when authenticating against the temporary token, then restrict access to only that role... when the account is created, send them to a re-login page (terminating the authentication token). This will simplify your security model.

Resources