Keycloak - Assign User to group from registration form - keycloak

I'm trying to create a custom registration form in Keycloak that will create the user and assign them to a group depending on a team drop down selection. Here is an example of my problem:
I have multiple teams that will be using keycloak and each team will have their own group in keycloak mapping out all the roles that they need access to. One app that will be using keycloak authentication is Grafana. When a user goes to Grafana and tries to register for a new account via keycloak, it creates the user, but because the user isn't assigned to a group, they land at an error page in Grafana because they don't have any privilege.
I'm trying to limit the amount of manual work to assign hundreds of users to groups after they register. I don't have access to LDAP or Active Directroy.
Here is an example of what i've tried in my custom register.ftl template.
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('team',properties.kcFormGroupErrorClass!)}">
<div class="${properties.kcLabelWrapperClass!}">
<label for="groups" class="${properties.kcLabelClass!}">Team</label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<select class="${properties.kcInputClass!}" id="groups" name="groups" value="${(register.formData['groups']!'')}">
<option value="group1">Group 1</option>
<option value="group2">Group 2</option>
<option value="group3">Group 3</option>
</select>
</div>
</div>
I was successfully able to add the group as a user attribute, and then thought I could execute a script after that uses the rest API to then assign the group, but I haven't had much luck with that either. I would like to stay away from assigning everyone to a default "view only" group because some groups don't need to be able to view all the apps that we will use.
If anyone has any ideas or could help point me in the right direction, please let me know. I have limited knowledge HTML & Javascript but know my way around Python.

Related

How does the lastpass icon determine when to appear on a form input?

The lastpass autofill icon appears on certain form fields, and on my site it has appeared unexpectedly on an input, with autocomplete="off", with no id and a name of CatName_autocomplete.
I understand I can add an attribute to disable it, but unless I do this for everything in my site, plus any other rival password managers, it could potentially crop up elsewhere. It interferes with my own custom javascript autocomplete functionality that I have on the control because it doesn't trigger the correct events to work properly.
Is there a way to find out the specific underlying logic it uses to decide whether to appear in an input? This would allow me to check I don't accidentally write misleading inputs that trigger it, or that I can know to put the attribute to disable it onto those I know would trigger.
I'm sure it's far more complicated than this, but in case it helps anyone: I disabled the icon in many fields on my page just by removing 'id' from the name attribute of the FIRST input element.
<input type="text" class="form-control" placeholder="Schedule ID"
name="scheduleId" [(ngModel)]="scheduleId" aria-label="Schedule ID"/>
triggers icons on the page, not just on this form.
<input type="text" class="form-control" placeholder="Schedule ID"
name="schedule" [(ngModel)]="scheduleId" aria-label="Schedule ID"/>
does not.

taking employees data from the active directory into html page in the sharepoint

i have a sharepoint intranet site for my company and i have made a new design for team page using HTML and CSS (the HTML page is in a web part in the sharepoint).
how can i take employees data from the active directory into my html page?
i want to insert the date from active directory into this:
<div class="card-body text-center mt-4">
<h4 class="card-title">William</h4>
<p class="card-text">Tel.: 0000000000
<br>Fax: 000000000000
<br>Mobil: 00000000000
<br>E-Mail: William#w.com</p>
</div>
thanks :)
I would suggest you configure User Profile Sync and then read user profile by REST api.
User Profile Synchronization reference
Then, get users by /_api/web/siteusers
Then, get user profile by /_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=#v)?#v='domain\username' Rererence here.

How to scrape a form that requires field validation by user?

I'm trying to scrape prices from this site:
https://www.pensketruckrental.com/quote/start.html
I can easily enter the form data, and I can activate the "Get A Quote" button and click it.
What I can't seem to do is get the form data to submit using a web scraper (I'm just doing it in VBA). When I input text using the scraper, the button remains grayed out, and even making a .click call on the button just displays errors on the form telling you not to leave the fields blank. Apparently it only recognizes data when you use an input device?
The code for one of the required fields, pickupLocation, is the following when I enter it manually (and thus the button works and the form can be submitted):
<input
type="text"
id="pickUpLocation"
name="pickUpLocation"
class="penskeValidateField penskeGoogleTypeAhead penskeInlineError ng-isolate-scope ng-touched ng-focused ng-dirty ng-valid-penske-err_loc_empty_sa ng-valid ng-valid-parse ng-valid-required"
aria-invalid="false"
aria-required="false"
country="rentalEntryCtrl.formItems.country"
penske-validate-field="pickuplocation"
required=""
autocompelete="off"
data-penske-placeholder="rentalEntryCtrl.activePlaceHolders.pickUpLocation"
ng-model="rentalEntryCtrl.formItems.pickupLocationSearchCriteria.address"
autocomplete="off">
And when I enter the data automatically using my scraper the tag & attributes read as follows:
<input
type="text"
id="pickUpLocation"
name="pickUpLocation"
class="penskeValidateField penskeGoogleTypeAhead penskeInlineError ng-pristine ng-isolate-scope ng-invalid ng-invalid-required placeholder ng-touched"
aria-invalid="true"
aria-required="true"
country="rentalEntryCtrl.formItems.country"
penske-validate-field="pickuplocation"
required=""
autocomplete="off"
data-penske-placeholder="rentalEntryCtrl.activePlaceHolders.pickUpLocation"
ng-model="rentalEntryCtrl.formItems.pickupLocationSearchCriteria.address"
autocompelete="off">
So of course I tried to copy the fields in the first code block into the second code block using setAttribute(), but even though I could change the attributes, I still couldn't get the form to submit properly.
I've looked at others that have dealt with something somewhat similar with autocorrect; their solutions have involved looking at the header and responses and just using the straight XHR to loop through the autocomplete queries, but the pricing information I'm scraping comes after several pages of form submissions, so that's not an option here.
I'm stuck I think; any ideas on how to populate the form and click the button/submit via my scraper?

Add MailChimp subscriber to group with signup form, not API

I know you can do this with the API, but not sure about the regular signup form.
Does anyone know if it is possible to add some code to the advanced signup form in MailChimp that would automatically add them to a specific group within my list?
I am only collecting the email address and I don't want the subscriber to have to select the group manually. If they are using that form, I want them added to that group.
I have asked MailChimp for help, but they tell me that their customer support doesn't code and that I should hire an expert.
Perhaps a segment of the relevant code may help:
<form action="http://lalala.us2.list-manage1.com/subscribe/post" method="post">
<input type="hidden" name="u" value="345fc4974810ef65c8276c8">
<input type="hidden" name="id" value="25c4d1b28">
<table cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td align="right" class="formLabel"><strong>Email Address</strong> <span class="asterisk">*</span>:</td>
<td align="left">
<input type="email" autocapitalize="off" autocorrect="off" name="MERGE0" id="MERGE0" size="25" value="*|MERGE0|*">
<br><span class="error">*|HTML:EMAILERROR|*</span></td>
</tr>
Is there a hidden input type that I can add with a list grouping name that will auto add them to a group?
This is an old question, but I came across it looking for the answer myself and couldn't find a good answer anywhere (including the other answer here which is poor at best). When I couldn't find anything on this I was able to figure it out with a little experimentation.
It requires a couple steps. First, add your Group and the options you want the Group to contain (it can only be 1 if you want). Initially make sure the Group is not set to hidden. Go to your main default sign-up form in MailChimp under Sign Up Forms > General Forms. Verify the Group option(s) are visible and then use the Sign up form URL to visit your hosted sign-up form. Now, open the raw HTML in your browser using right-click > View Source. You need to find the INPUT element for the group / option you want. It will probably look something like this:
<input type="checkbox" data-dojo-type="dijit/form/CheckBox" id="group_8" name="group[13257][8]" value="1" class="av-checkbox">
The name parameter is the critical thing here. Copy and paste that entire input element inside your custom form. Now, use inline CSS to hide it and HTML to hard-code it to checked. You can also remove extra stuff too. The final version in your custom form should look something like this:
<input type="checkbox" id="group_8" name="group[13257][8]" value="1" checked="checked" style="display:none">
This will ensure that it is not visible to the user but it will automatically add them to the group defined by the name parameter that you grabbed from the form which showed it.
The final step is to go back and make sure you set that Group to Hidden to make sure it doesn't inadvertently show up on other forms.
Pretty simple!
All I did was delete the other checkboxes (as well as the unordered list and list item tags around them) and change the checkbox representing the default group I wanted into a hidden field. Literally just type="hidden" instead of type="checkbox" and that did the trick.
You should be able to add a hidden input field with the name of the MERGE TAG set for the specific group.
However, for this functionality it would be much easier to utilize the MailChimp API (even though your question suggests you'd rather not).

Custom label and values in select list in Spring MVC

I have a user drop down in my JSP page where I show the user list. In the drop down I need to show the user name and email as the label while value will be user id and user email address. So I need to concatenate the properties of my user instance to show the proper label and values.
What is the best possible approach to do this in the Spring MVC?
I can iterate over the list in my Spring Controller and concatenate the properties and then create a new list which will be displayed in the page. This is the way I can think of.
Any better ideas?
Add users list object to the model and use standard tag lib to build the html
<select id="users" name="users">
<c:forEach items="users" var="user">
<option value="${user.id}">${user.name} [${user.email}]</option>
</c:forEach>
</select>