<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rannmann</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rannmann"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Rannmann"/>
	<updated>2026-06-27T23:33:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Accessing_the_current_user_object&amp;diff=77977</id>
		<title>Accessing the current user object</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Accessing_the_current_user_object&amp;diff=77977"/>
		<updated>2012-11-30T17:53:49Z</updated>

		<summary type="html">&lt;p&gt;Rannmann: /* External Links */  Updated URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
For every request in Joomla!, there is one user. Information about this user is readily available through the Joomla! framework in the form of an object. To get this object for the current user, use the following member function of JFactory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, to get information about any other registered user you can call the function with a user &#039;id&#039;, e.g. for user &#039;99&#039;; or a username e.g. &#039;johnsmith&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser(99);&lt;br /&gt;
        $user =&amp;amp; JFactory::getUser(&#039;johnsmith&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Getting a reference through getUser() ensures that only one user object is created during any one Joomla! request, saving on memory and processing time. Most of the information about the user is available through public member variables of the user object. This code displays the current user&#039;s name, email, user name, user type, and group id:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Your name is {$user-&amp;gt;name}, your email is {$user-&amp;gt;email}, and your username is {$user-&amp;gt;username}&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Your usertype is {$user-&amp;gt;usertype} which has a group id of {$user-&amp;gt;gid}.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Object Member Variables and Parameters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are the relevant member variables automatically generated on a call to getUser():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;id - The unique, numerical user id. Use this when referencing the user record in other database tables.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;name - The name of the user. (e.g. Vint Cerf)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;username - The login/screen name of the user. (e.g. shmuffin1979)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;email - The email address of the user. (e.g. crashoverride@hackers.com)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;password - The encrypted version of the user&#039;s password&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;password_clear - Set to the user&#039;s password only when it is being changed. Otherwise, remains blank.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;usertype - The role of the user within Joomla!. (Super Administrator, Editor, etc...)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;gid - Set to the user&#039;s group id, which corresponds to the usertype.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;block - Set to &#039;1&#039; when the user is set to &#039;blocked&#039; in Joomla!.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;registerDate - Set to the date when the user was first registered.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;lastvisitDate - Set to the date the user last visited the site.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;guest - If the user is not logged in, this variable will be set to &#039;1&#039;. The other variables will be unset or default values.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
In addition to the member variables (which are stored in the database in columns), there are parameters for the user that hold preferences. To get one of these parameters, call the getParam() member function of the user object, passing in the name of the parameter you want along with a default value in case it is blank.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
	$language = $user-&amp;gt;getParam(&#039;language&#039;, &#039;the default&#039;);&lt;br /&gt;
	&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Your language is set to {$language}.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Determining Status ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Frequently, you will just want to make sure the user is logged in before continuing. The &#039;guest&#039; property will be set to &#039;1&#039; when the current user is not logged in. When the user is authenticated, &#039;guest&#039; will be set to &#039;0&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
	&lt;br /&gt;
	if ($user-&amp;gt;guest) {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You must login to see the content. I want your email address.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	} else {&lt;br /&gt;
		?&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;h1&amp;gt;Impromptu leftovers salad that goes well with fish&amp;lt;/h1&amp;gt;&lt;br /&gt;
		&amp;lt;ul&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;1/2 cup chopped celery&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;1/4 cup raisins&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;1 teaspoon Extra Virgin Olive Oil&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;2 tablespoons of faux Thai lemongrass marinade&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;1/4 cup shredded fresh basil&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;Sprinkling of dill weed&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;Big pinch of kosher salt&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;Several lettuce leaves&amp;lt;/li&amp;gt;&lt;br /&gt;
		&amp;lt;/ul&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;p&amp;gt;Wash the lettuce and basil and place in a salad bowl.&lt;br /&gt;
Get out a much smaller bowl and swish around all of the remaining ingredients. Pour this over the greens and toss.&lt;br /&gt;
Serves two.&amp;lt;/p&amp;gt;&lt;br /&gt;
		&amp;lt;?php&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Privileges ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Not all authenticated users are given equal rights. For instance, a Super Administrator may be able to edit anyone&#039;s content, while a Publisher may only be able to edit their own. The authorize() member function can be used to determine if the current user has permission to do a certain task. The first parameter is used to identify which component or function we wish to authenticate against. The second represents the task. The third and fourth are optional; they further break the permissions down into record types and ownership respectively.&lt;br /&gt;
&lt;br /&gt;
In Joomla! 1.5, the rights for all of the core components are stored in libraries/joomla/user/authorization.php. These are available to all extensions wherever authentication is required. If the permission scheme of the Content component suits your extension&#039;s needs, you can use code similar to the following to determine what functions to give to a specific user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
	&lt;br /&gt;
	if ($user-&amp;gt;authorize(&#039;com_content&#039;, &#039;edit&#039;, &#039;content&#039;, &#039;all&#039;)) {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You may edit all content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	} else {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You may not edit all content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if ($user-&amp;gt;authorize(&#039;com_content&#039;, &#039;publish&#039;, &#039;content&#039;, &#039;own&#039;)) {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You may publish your own content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	} else {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You may not publish your own content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The permissions for core functions may not be suitable for your extension. If this is the case, you can create your own permissions. You will probably want to add this code in a place where it will always be executed, such as the beginning of the component you are building or in a systemwide plugin. First, you need to get an authorization object using the getACL() member function of JFactory. This works like getUser() in that it only creates one authorization object during any particular Joomla! request. Once you have this object, call the addACL() member function to add permissions. Pass in the name of your component or function, the task name, the string &#039;users&#039;, and the user type (in lowercase) respectively. If you want to also define record sets and ownership, pass those in as an additional two parameters.&lt;br /&gt;
&lt;br /&gt;
Note that in Joomla! 1.5, permissions are not inherited. For example, if you give an Administrator the right to edit content, Super Administrators do not automatically get this right; you must grant it separately.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	$auth =&amp;amp; JFactory::getACL();&lt;br /&gt;
	&lt;br /&gt;
	$auth-&amp;gt;addACL(&#039;com_userinfo15&#039;, &#039;persuade&#039;, &#039;users&#039;, &#039;super administrator&#039;);&lt;br /&gt;
	$auth-&amp;gt;addACL(&#039;com_userinfo15&#039;, &#039;persuade&#039;, &#039;users&#039;, &#039;administrator&#039;);&lt;br /&gt;
	$auth-&amp;gt;addACL(&#039;com_userinfo15&#039;, &#039;persuade&#039;, &#039;users&#039;, &#039;manager&#039;);&lt;br /&gt;
&lt;br /&gt;
	$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
	&lt;br /&gt;
	if ($user-&amp;gt;authorize(&#039;com_userinfo15&#039;, &#039;persuade&#039;)) {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You may persuade the system to do what you wish.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	} else {&lt;br /&gt;
		echo &amp;quot;&amp;lt;p&amp;gt;You are not very persuasive.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Information about the current user is readily available in any part of your Joomla! extension. You need only fetch the object and access the member variables. You can authorize the user against the core permissions set, or create your own to suit your needs.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
[http://api.joomla.org/Joomla-Platform/User/JUser.html JUser API documentation] see getInstance.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]][[Category:Framework]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Plugin Development]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Rannmann</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J2.5:LDAP_Authentication&amp;diff=63755</id>
		<title>J2.5:LDAP Authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J2.5:LDAP_Authentication&amp;diff=63755"/>
		<updated>2011-12-22T01:31:37Z</updated>

		<summary type="html">&lt;p&gt;Rannmann: Created page with &amp;quot;= LDAP Authentication in 1.7 = LDAP Authentication is disabled by default because it needs to first be configured before enabled.  To configure this plug-in, go to the Plug-in Ma...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= LDAP Authentication in 1.7 =&lt;br /&gt;
LDAP Authentication is disabled by default because it needs to first be configured before enabled.  To configure this plug-in, go to the Plug-in Manager and search for &amp;quot;Authentication - LDAP&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The options should look similar to this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Host: localhost&lt;br /&gt;
Port: 389&lt;br /&gt;
LDAP V3: No&lt;br /&gt;
Negotiate TLS: No&lt;br /&gt;
Follow Referrals: No&lt;br /&gt;
Authorisation Method: Bind and Search&lt;br /&gt;
Base DN:&lt;br /&gt;
Search String:&lt;br /&gt;
User&#039;s DN:&lt;br /&gt;
Connect Username:&lt;br /&gt;
Connect Password:&lt;br /&gt;
Map: Full Name: fullName&lt;br /&gt;
Map: email: mail&lt;br /&gt;
Map: UserID: uid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming everything on your server is setup correctly (and the standard port is used), the only information that needs changed for a Bind and Search method is:&lt;br /&gt;
* Host&lt;br /&gt;
* LDAP V3&lt;br /&gt;
* Base DN&lt;br /&gt;
* Search String&lt;br /&gt;
&lt;br /&gt;
=== What these entries mean ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; width=&amp;quot;40&amp;quot; | Option Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; width=&amp;quot;400&amp;quot; | Meaning&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; width=&amp;quot;150&amp;quot; | Examples&lt;br /&gt;
|-&lt;br /&gt;
| Host&lt;br /&gt;
| Host name of the LDAP server&lt;br /&gt;
| localhost  openldap.mycompany.org  ldaps://ldap.company.org&lt;br /&gt;
|-&lt;br /&gt;
| Port&lt;br /&gt;
| Port to connect to host&lt;br /&gt;
| 389&lt;br /&gt;
|-&lt;br /&gt;
| LDAP V3&lt;br /&gt;
| Whether or not the LDAP server is using LDAP Version 3 or not&lt;br /&gt;
| No, Yes&lt;br /&gt;
|-&lt;br /&gt;
| Negotiate TLS&lt;br /&gt;
| Negotiate TLS encryption with the LDAP server (requires all traffic to be encrypted)&lt;br /&gt;
| No, Yes&lt;br /&gt;
|-&lt;br /&gt;
| Follow Referrals&lt;br /&gt;
| Sets the value of LDAP_OPT_REFERRALS (Set to &amp;quot;No&amp;quot; for Windows 2003 servers)&lt;br /&gt;
| No, Yes&lt;br /&gt;
|-&lt;br /&gt;
| Authorisation Method&lt;br /&gt;
| How to authorize against the LDAP server&lt;br /&gt;
| Bind and Search, Bind Directly as User&lt;br /&gt;
|-&lt;br /&gt;
| Base DN&lt;br /&gt;
| The lowest-level Distinguished Name&lt;br /&gt;
| dc=company,dc=com,  o=company.com,  c=us,o=company.com&lt;br /&gt;
|-&lt;br /&gt;
| Search String&lt;br /&gt;
| Only used with Bind and Search - a query string used to search for the user, where [search] is directly replaced by search text from the login field&lt;br /&gt;
| uid=[search]&lt;br /&gt;
|-&lt;br /&gt;
| User&#039;s DN&lt;br /&gt;
| Only used with Bind Directly as User - a string used to authenticate as a user, where [username] is directly replaced by the username from the login field&lt;br /&gt;
| uid=[username],dc=company,dc=com&lt;br /&gt;
|-&lt;br /&gt;
| Connect Username&lt;br /&gt;
| Only used if not an anonymous lookup - administrator username&lt;br /&gt;
| admin&lt;br /&gt;
|-&lt;br /&gt;
| Connect Password&lt;br /&gt;
| Only used if not an anonymous lookup - administrator password&lt;br /&gt;
| password&lt;br /&gt;
|-&lt;br /&gt;
| Map: Full Name&lt;br /&gt;
| LDAP Attribute which holds the user&#039;s full name&lt;br /&gt;
| fullName,  givenName,  name&lt;br /&gt;
|-&lt;br /&gt;
| Map: email&lt;br /&gt;
| LDAP Attribute which holds the user&#039;s email address&lt;br /&gt;
| mail&lt;br /&gt;
|-&lt;br /&gt;
| Map: User ID&lt;br /&gt;
| LDAP Attribute which holds the user&#039;s ID&lt;br /&gt;
| uid&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Configuration ===&lt;br /&gt;
On an Ubuntu server accessing an external LDAP V3 server, using the &amp;quot;Bind and Search&amp;quot; method with anonymous lookups enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Host: ldaps://ldap.us.site&lt;br /&gt;
Port: 389&lt;br /&gt;
LDAP V3: Yes&lt;br /&gt;
Negotiate TLS: No&lt;br /&gt;
Follow Referrals: No&lt;br /&gt;
Authorisation Method: Bind and Search&lt;br /&gt;
Base DN: dc=site&lt;br /&gt;
Search String: uid=[search]&lt;br /&gt;
User&#039;s DN:&lt;br /&gt;
Connect Username:&lt;br /&gt;
Connect Password:&lt;br /&gt;
Map: Full Name: fullName&lt;br /&gt;
Map: email: mail&lt;br /&gt;
Map: UserID: uid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Errors =&lt;br /&gt;
Just because some these aren&#039;t documented anywhere else on the web, this seems like the best place to keep track of some common, or uncommon but hard to diagnose errors.&lt;br /&gt;
== 500 Error ==&lt;br /&gt;
If after enabling this plugin you are receiving 500 errors when attempting to login, make sure that the php5-ldap package is installed (and loaded) on the server.&lt;br /&gt;
&lt;br /&gt;
== Invalid Credentials ==&lt;br /&gt;
If you cannot login with credentials you know to be accurate and are using an LDAP server which requires &amp;quot;ldaps://&amp;quot; instead of &amp;quot;ldap://&amp;quot;, the protocol prefix must be applied in the &amp;quot;Host&amp;quot; field.&lt;/div&gt;</summary>
		<author><name>Rannmann</name></author>
	</entry>
</feed>