I am new to LifeRay and trying to fetch user from LDAP programmatically inside liferay portlet.
Can any one let me know how to pass a userID to the LDAP server and get the corresponding user?
It would be really great if a sample program can be included here for reference.
regards,
Deepak.
Preface
You need to specify your portal version and release (ex: 6.1 EE, 6.1 CE, 7.0 EE, DXP, etc) for accurate instruction. It would also be helpful if you state your reason because very often in Liferay a new developer tries to solve a problem that has already been solved. Liferay 6.x ships with a portlet that allows you to manage LDAP / AD integration as well as robust properties configurations. Your ability to get this to work with their programmatic API will depend also on your ability to configure the LDAP integration correctly.
Configuration
Before successfully using the programmatic API I suggest you first configure LDAP integration via the portlet and/or the config files. You can find the LDAP portlet doing the following:
Control Panel
Portal Settings
Authentication
LDAP
From there you will need to set your URI, ports, field maps, etc. Test your connection.
Programmatic API
What you actually want to do is unknown so I'll give you what I believe are the most useful utilities. Pseudo code would look something like
User user = null;
ThemeDisplay themeDisplay;
try {
themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
user = PortalLDAPImporterUtil.importLDAPUser(themeDisplay.getCompanyId(), "email", "screenanme");
UserLocalServiceUtil.addUser(user);
} catch(Exception e) {
e.printStackTrace();
}
Related
We have added several Social Logins to our Liferay 7.3 portal. These include the built-in Facebook and OpenId Connect capabilities as well as custom filters for Twitter, LinkedIn, and so on. OpenId Connect is configured for Google login.
This all works fine, but I need to change the link in the login page from "OpenId Connect" to "Google".
I have discovered that the value is set in the key open-id-connect-configuration-name in the language files in the portal-security-sso-openid-connect-api module. It is then accessed by the getName() method of the com.liferay.portal.settings.authentication.openid.connect.web.internal.portal.settings.configuration.admin.display.OpenIdConnectPortalSettingsConfigurationScreenContributor class. I believe this contributor supplies the value to the navigator for use as the label.
My question is what is the easiest and most maintainable way to go about changing this value? My thought was to supply alternate Language_*.properties files, but I'm not sure how to override the existing ones. Would a JSP hook of the portal-security-sso-openid-connect-api module allow me to do this?
I don't know a clean way - hopefully someone will chime in with one - but I had the same issue and had to solve it with a small piece of JavaScript in navigation.jspf:
<script>
$( document ).ready(function() {
$(".taglib-text").filter(function () {
return ($(this).text() === 'OpenId Connect')
}).text("Google");
});
</script>
While this works it's still a bit weird since clicking the link will go to the OpenId Connect portlet that has a drop down with a single item - Google - that is selected, and then the user has to click another Login button. I know this is to allow multiple OpenID Connect clients, but I'd sure like a direct method for Google.
I need to extend my Backoffice login form and add two new fields to it. Then I need to access the login info in my Java code.
Extending Backoffice Login Page says I need to use LoginInformationHandler.
I haven't found information on how to do this. Should I inject it as Spring bean? I can't see configuration for it in spring-xml files in my application or OOTB. The only constructor available needs TypedSettingsMap loginInfo, which would just create new LoginInfoHandler or something like that.
So, what's the solution for this?
Yes, LoginInformationHandler is a service that you can inject into your service / facade.
Then, you would need to get the data like this:
loginInformationHandler.getLoginInformation(“tenant”);
I want to use Sitecore security to make access to certain documents on a site require registration/login. However the client would like to show links to these documents to anonymous users as a way to let them know that if they register/login then they will get access to these protected documents.
Is there some simple way to do this in Sitecore? The only thing I can think of off the top of my head is to use some sort of Security Disabler to get the list of documents and display the links on the page.
As Thomas Therkildsen suggests, you can use the Security Disabler, although Sitecore's preferred method is to use a user switcher.
using (new Sitecore.Security.Accounts.UserSwitcher(userWithMoreRights))
{
// ...
}
SecurityDisabler basically gives the code the right to do anything it wants, whereas UserSwitcher is more restrictive.
See the Security API cookbook for more information.
You could use the SecurityDisabler:
using (new SecurityDisabler())
{
//code to get links
}
I am using Liferay 6 for development .
I have developed a Custom Login Portlet using Struts2 .
I am able to display my Custom Login page , On click of the Submit Button after validating the credentials aganist our MYSQL Databse , please tell me how can i display my 4 other Custom Portlets on entering valid credentials ??
please guide me what is the concept i should refer for this in liferay
( I am using Liferay 6 for development )
Okay, the way I would suggest you do this is by:
adding the 4 other portlets to your Custom Login page (or add a redirect on successful login, and them to the page you redirect to)
Set the permissions of your Custom Portlets to be viewable by only authenticated users. This can be done by removing Guest "View" permissions. This way a non-authenticated user or "Guest" won't see your portlets when the go to the page.
Does this answer your question?
~~ EDIT IN RESPONSE TO COMMENT ~~
Okay, so if you're using Struts, instead of redirecting to a JSP file, you want to redirect to a URL instead. So instead of /view/result.jsp it should be something like http://yoursite.com/page_with_4_portlets_on_it or just a relative URL /page_with_4_portlets_on_it (if the two pages are on the same Navigation level.
HOWEVER:
If you're new to Liferay then I would strongly suggest you use Liferay's inbuilt Portlet architecture using their MVCPortlet class. This will handle all the mappings, and workings that you have to manually write for using Struts. Then you can implement a doPost() method and do a ActionResponse.sendRedirect("/page_with_4_portlets_on_it");
Then this means that when your form action completes Liferay will redirect the user to the page you've specified.
The best place to get started with Liferay 6 portlets, the Liferay way is here.
I'm in charge of a Sharepoint collection, and a user asks this. Is it possible that when a user creates an item, some fields are automatically filled with some info, such as email address and location?
Authentication uses Active Directory, so every user is identified when using Sharepoint. The only issue is that, being in a big corporate company, I don't have any access to the server, so it must be feasible through configuration of said site/list or using Sharepoint Designer, but I can't and won't be allowed to deploy anything server side.
Any idea?
With your limitations, your best bet would be a combination of ajax (I suggest jquery) and sharepoint webservices (if necessary), you need to do a XmlHttpRequest in the userdisp.aspx page, if this page has all the info you need, then get it, otherwise, get the currently logged account and use it to query the webservices (this part I'm not sure if theres a method that will return this info).
This all works using only the browser (Content Editor WebPart) or the SharePoint Designer client.