Friday, April 11, 2008

User Access Control in Drupal 6

In this article by David Mercer, we will look at an entirely different aspect of running a Drupal website. Once we have added the functionality to the site, we now have to give some thoughts about how this functionality is to be accessed, or by whom. As the site grows, you will most likely feel the need to delegate certain responsibilities to various people. Alternatively, you might organize a team of people to work on specific aspects of the site. Whatever is required, at some stage you will have to make decisions about who can do what, and Drupal makes sure that it is possible to do precisely this.

Having Drupal simplify the implementation of your access control policies does not mean that the task is a trivial one. There is still much thought that needs to go on behind the scenes in order to create a sophisticated, and above all, effective policy for controlling access to the site. Because of this, we will spend a bit of time exploring the ramifications of the various choices available, instead of simply listing them. Taking a holistic approach to implementing an access control policy will ensure you don't end up with any nasty surprises down the line.

Specifically, this article will look at Planning an access policy, Roles, Users, and Access rules.

Before we continue, it is worth pointing out that at the moment of adding the basic functionality you are more than likely using the administrative user (user number 1) for all the site's development needs. That is absolutely fine, but once the major changes to the site are completed, you should begin using a normal administrative user that has only the permissions required to complete your day-to-day tasks. The next section will highlight the general philosophy behind user access, which should make the reason for this clear.
Planning an Access Policy

When you think about how your site should work, focus in on what will be required of yourself, other community members, or even anonymous users. For instance:

* Will there be a team of moderators working to ensure that the content of the site conforms to the dictates of good taste and avoids material that is tantamount to hate speech, and so on?
* Will there be subject experts who are allowed to create and maintain their own content?
* How much will anonymous visitors be allowed to become involved, or will they be forced to merely window shop without being able to contribute?

Some of you might feel that the site should grow organically with the community, and so you want to be extremely flexible in your approach. However, you can take it as given that Drupal's access policies are already flexible, given how easy it is to reconfigure, so it is good practice to start out with a sensible set of access rules, even if they are going to change over time. If you need to make modifications later, so be it, but at least there will be a coherent set of rules from the start.

The first and foremost rule of security that can be applied directly to our situation is

Grant a user permissions sufficient for completing the intended task, and no more!

Our entire approach is going to be governed by this rule. With a bit of thought you should be able to see why this is so important. The last thing anyone wants is for an anonymous user to be able to modify the personal blog of a respected industry expert. This means that each type of user should have carefully controlled permissions that effectively block their ability to act outside the scope of their remit.

One upshot of this is that it is better to create a larger number of specific roles, rather than create a generic role or two, and allow everyone to use those catch-all permissions.

A role constitutes a number of permissions that define what actions any members of that role can and can't perform.

We will explore roles in detail in the next section!

Drupal gives us fine-grained control over what users can accomplish, and you should make good use of this facility. It may help to think of your access control using the following figure (this does not necessarily represent the actual roles on your site—it's just an example):



The shaded region represents the total number of permissions available for the site. Contained within this set are the various roles that exist either by default, like the Anonymous users role, or those you create in order to cater for the different types of users the site will require—in this case, the Blog Writer users and Forum Moderator users roles.

From the previous diagram you can see that the Anonymous users role has the smallest set of permissions because they have the smallest area of the total diagram. This set of permissions is totally encapsulated by the Forum Moderator users and Blog Writer users—meaning that forum moderators and blog writers can do everything an anonymous user does, and a whole lot more.

Remember, it is not compulsory that forum moderators encapsulate all the permissions of the anonymous users. You can assign any permissions to any role—it's just that in this context it makes sense that a forum moderator should be able to do everything an anonymous user can and more.

Of course, the blog writers have a slightly different remit. While they share some privileges in common with the forum administrators, they also have a few of their own. Your permissions as the primary or administrative user encompass the entire set, because there should be nothing that you cannot control.

It is up to you to decide which roles are best for the site, but before attempting this it is important to ask: What are roles and how are they used in the first place? To answer this question, let's take a look at the practical side of things in more detail.
Roles

It may seem a bit odd that we are not beginning a practical look at access control with a discussion on users. After all, it is all about what users can and cannot do! The problem with immediately talking about users is that the focus of a single user is too narrow, and we can learn far more about controlling access by taking a more broad view using roles. Once we have learned everything there is to know about roles, actually working with users becomes a trivial matter.

As mentioned, a user role in Drupal defines a set of rules that must be obeyed by all the users in that role. It may be helpful to think of a role as a character in a play. In a play, an actor must always be true to their character (in the same way a user must be faithful to their role in Drupal)—in other words, there is a defined way to behave and the character never deviates (no matter which actor portrays the character).

Creating a role in Drupal is very easy. Click the User management link under Administer and select the Roles tab to bring up the following:



As you can see, we have two roles already defined by default—the anonymous user and the authenticated user. It is not possible to change these, and so the Operations column is permanently set to locked. To begin with, the anonymous user (this is any user who is browsing the site without logging in) has very few permissions set, and you would more than likely want to keep it this way, despite the fact it is possible to give them any and all permissions.

Similarly, the authenticated user, by default, has only a few more permissions than the anonymous user, and it is also sensible to keep these to a minimum. We will see in a little while how to go about deciding who should have which permissions.

In order to add a new role, type in a name for the role and click Add role, and you're done. But what name do you want to add? That's the key question! If you are unsure about what name to use, then it is most likely you haven't defined the purpose of the role properly. To see how this is done, let's assume we require a forum moderator who will be a normal user in every way, except for the ability to work directly on the forums (to take some of the burden of responsibility off the administrator's hands) to create new topics, and to edit the content if necessary.

To get the ball rolling, type in forum moderator and click Add role—actually, you might even want to be more specific and use something like conservation forum moderator if there will be teams of forum moderators—you get the general idea.

Now the roles page should display the new role with the option to edit it, shown in the Operations column. Click edit role in order to change the name of the role or delete it completely. Alternatively, click edit permissions to deal with the permissions for this specific role (we discuss permissions in a moment so let's leave this for now).

Our work is just beginning, because now we need to grant or deny the various permissions that the forum moderator role will need in order to successfully fulfill its purpose. New roles are not given any permission at all to begin with—this makes sense, because the last thing we want is to create a role only to find that it has the same permissions as the administrative user.

Chances are you will need to add several roles depending on the needs of the site, so add at least a blogger user that can edit their own blog—we will need a few different types to play with later on.

Let's move on and take a look at how to flesh out this new role by setting permissions.

This article has been extracted from: Building Powerful and Robust Websites with Drupal 6
Building Powerful and Robust Websites with Drupal 6 Build your own professional blog, forum, portal or community website with Drupal 6

* Set up, configure, and deploy Drupal 6
* Design and implement your website's look and feel
* Easily add exciting and powerful features
* Promote, manage, and maintain your live website

For more information, please visit:
www.PacktPub.com/drupal-6-create-powerful-websites/book
Permissions

In order to work with permissions, click the Permissions link under User management and you should be presented with a screen much like the following (notice the new forum moderator role on the right-hand side of the page):



As you can see, this page lists all of the available permissions down the left-hand column and allows you to enable or disable that permission by checking or un-checking boxes in the relevant column. It is easy enough to see that one traverses the list, selecting those permissions required for each role. What is not so easy is actually determining what should and shouldn't be enabled in the first place.

Notice too that the permissions given in the list on the left-hand side pertain to specific modules. This means that if we change the site's setup by adding or removing modules, then we will also have to change the permissions on this page.

Most times a module is added, you will need to ensure that the permissions are set as required for that module, because by default no permissions are granted.

What else can we learn from the permissions page shown in the previous screenshot? Well, what does each permission precisely mean? There are quite a few verbs that allow for completely different actions. The following lists the more common, generic ones, although you might find one or two others crop up every now and then to cater for a specific module:

* administer: gives the user the ability to affect the function of a module. For example, granting administer rights to the locale module means that the user can add or remove languages, manage strings, and even export .po files. This permission should only ever be given to trusted users, and never to anonymous users.
* access: gives the user the ability to make use of a module without being able to affect it in any way. For example, granting access rights to the comment module allows a user to view comments without being able to delete, edit, or reply to them.
* create: gives the user the ability to create content of some sort. For example, granting rights to create stories allows users to do so, but does not also give them the ability to edit those stories.
* edit any/own: gives the user the ability to work with either anyone's content or specifically the content they have created—depending on whether edit any or edit own is selected. For example, granting edit own rights to the blog module means that the user can modify their own blogs at will.
* delete any/own: applies to content related modules such as Node and empowers users to remove either anyone's content or confine them to removing only content posted by themselves. For example, setting delete own blog entry allows users to take back any blog postings they may regret having published.

There are also other module-specific permissions available, and it is recommended that you play around and understand any new permission(s) you set.

Previously, assigning the edit own permission automatically provided the delete own permission. For added security, delete own permissions for individual core content types have been removed from all roles and should be assigned separately.

How do we go about setting up the required permissions for the forum moderator user? If we look down the list of permissions shown on the Permission page, we see the following forum-related options (at the moment, the forum moderator permissions are those in the outermost column):



Enabling these three options, and then testing out what new powers are made available, should quickly demonstrate that this is not quite what we want.

If you are wondering how to actually test this out, you need to create a new user and then assign them to the forum moderator role. The following section on Users explains how to create new users and administer them properly. Jump ahead quickly and check that out so that you have a new user to work with if you are unsure how it is done.

The following point might make your life a bit easier:

Use two browsers to test out your site. The demo site's development machine has IE and Firefox. Keep one browser for the administrator and the other for anonymous or other users in order to test out changes. This will save you from having to log in and log out whenever testing new permissions.

When testing out the new permissions one way or another, you will find that the forum moderator can access and work with all of the forums—assuming you have created any.

However, notice that there are node module permissions available, which is quite interesting because most content in Drupal is actually a node. How will this affect the forum moderator? Disable the forum module permissions for the forum moderator user and then enable all the node options for the authenticated user before saving and logging out.

Log back in as the forum administrator and it will be clear that despite having revoked the forum based options for this user, it is possible to post to or edit anything in the forum quite easily by selecting the Create content link in the main menu. Is this what you expected?

It should be precisely what you expect because the forum moderator is an authenticated user, so they have acquired the permissions that came from the authenticated user. In addition, the forum posts are all nodes, and any authenticated user can add and edit nodes, so even though the forum moderator is not explicitly allowed to work with forums, through generic node permissions we get the same result:

Defined roles are given the authenticated user permissions.

Actually, the result is not entirely the same because the forum moderator can now also configure all the different types of content on the site, as well as edit any type of content including other people's blogs. This is most certainly undesirable, so log back in as the primary user and remove the node permissions (except the first one) from the authenticated user role. With that done, you can now spend some time building a fairly powerful and comprehensive role-based access control plan.

As an addendum, you might find that despite having a goodly amount of control over who does what, there are some things that are not easily done without help from elsewhere.
Users

A single user account can be given as many or as few permissions as you like via the use of roles. Drupal users are not really anything unless they already have a role that defines the manner in which they can operate within the Drupal framework. Hence, we discussed roles first.

Users can be created in two ways. The most common way is by registering on the site—if you haven't already, go ahead and register a new user on your site by clicking the Create new account link on the homepage just to test things out. Remember to supply a valid email address otherwise you won't be able to sign in properly. This will create an authenticated user, with any and all permissions that have been assigned to the authenticated user role.

The second way is to use the administrative user to create a new user. In order to do so, log on as the administrative user and click on Users in User management under Administer. Select the Add user tab and follow the instructions on that page. For example, I created a new forum moderator user by ensuring that the relevant role was checked:



You will need to supply Drupal with usernames, email addresses, and passwords. Once there are a couple of users to play around with, it's time to begin working with them.

Administering Users

The site's administrator is given complete access to the other users' account information. By clicking on the edit link shown to the right of each user account (under the Operations column heading) in the Users page under User management, it is possible to make any changes you require to a given user.

Before we do though, it's worth noting that the administration page itself is fairly powerful in terms of being able to administer individual users or groups of users with relative ease:



The upper box, Show only users where, allows you to specify several filter conditions to cut down the result set and make it more manageable. This will become more and more important as the site accumulates more and more users. Once the various filter options have been implemented, the Update options allow you to apply whatever changes are needed to the list of users selected (by checking the relevant checkbox next to their name).

Having both broad, sweeping powers as well as fine-grained control over users is one of the most valuable facilities provided by Drupal, and you will no doubt become very familiar with this page in due course.

Click on the edit link next to the forum moderator user and take a look at the Roles section. Notice that it is now possible to stipulate which roles this user belongs to. At present there are only two new roles to be assigned (yours might vary depending on which roles have been created on your setup):



Whenever a user is added to another role, they obtain the combined permissions of these roles. With this in mind, you should go about delegating roles in the following fashion:

1. Define the most basic user of the site by setting the anonymous user permissions.
2. Set permissions for a basic authenticated user (i.e. any Tom, Dick or Harry that registers on your site).
3. Create special roles by only adding the specific additional permissions that are required by that role, and no more. Don't re-assign permissions that the authenticated user already has.
4. Create new users by combining whatever roles are required for their duties or needs.



If you follow the steps above, you will be sure to always give the correct permissions to each role by avoiding redundancy and only applying permissions incrementally by role. Basically, you are building up a user's permissions from the most basic to the most complex without having to assign every single permission each time. It should be commonsense (although not a technical obligation) that a forum moderator would have all the permissions of an anonymous and authenticated user, plus a few more. Looking back to the first diagram in the section Planning an Access Policy you can see that, in this case, we would:

1. Define the anonymous user and authenticated user role permissions—an authenticated user should have all the permissions of an anonymous user, plus whatever else is needed by a basic site user.
2. Create new roles with only the additional permissions needed for both the forum moderator and blog user respectively—other than those given to the authenticated user.
3. Assign blog writers to the blog user role (they are automatically given the permissions granted to an authenticated user), and do the same for forum moderators and their role.

Other than using that strategy for assigning roles to users, the rest, as they say, is history. Play around with any new roles you create to ensure they behave as you expect and then move on.
User Settings

This section looks at how the site treats users, rather than discussing what users can and cannot do. However, you will find that some of the information in this section is important for the look and feel of the site.

Click on User settings under the User management. The following set of options is provided, beginning with user registration settings, as follows:




User Access Control in Drupal 6

In this article by David Mercer, we will look at an entirely different aspect of running a Drupal website. Once we have added the functionality to the site, we now have to give some thoughts about how this functionality is to be accessed, or by whom. As the site grows, you will most likely feel the need to delegate certain responsibilities to various people. Alternatively, you might organize a team of people to work on specific aspects of the site. Whatever is required, at some stage you will have to make decisions about who can do what, and Drupal makes sure that it is possible to do precisely this.

Having Drupal simplify the implementation of your access control policies does not mean that the task is a trivial one. There is still much thought that needs to go on behind the scenes in order to create a sophisticated, and above all, effective policy for controlling access to the site. Because of this, we will spend a bit of time exploring the ramifications of the various choices available, instead of simply listing them. Taking a holistic approach to implementing an access control policy will ensure you don't end up with any nasty surprises down the line.

Specifically, this article will look at Planning an access policy, Roles, Users, and Access rules.

Before we continue, it is worth pointing out that at the moment of adding the basic functionality you are more than likely using the administrative user (user number 1) for all the site's development needs. That is absolutely fine, but once the major changes to the site are completed, you should begin using a normal administrative user that has only the permissions required to complete your day-to-day tasks. The next section will highlight the general philosophy behind user access, which should make the reason for this clear.
Planning an Access Policy

When you think about how your site should work, focus in on what will be required of yourself, other community members, or even anonymous users. For instance:

* Will there be a team of moderators working to ensure that the content of the site conforms to the dictates of good taste and avoids material that is tantamount to hate speech, and so on?
* Will there be subject experts who are allowed to create and maintain their own content?
* How much will anonymous visitors be allowed to become involved, or will they be forced to merely window shop without being able to contribute?

Some of you might feel that the site should grow organically with the community, and so you want to be extremely flexible in your approach. However, you can take it as given that Drupal's access policies are already flexible, given how easy it is to reconfigure, so it is good practice to start out with a sensible set of access rules, even if they are going to change over time. If you need to make modifications later, so be it, but at least there will be a coherent set of rules from the start.

The first and foremost rule of security that can be applied directly to our situation is

Grant a user permissions sufficient for completing the intended task, and no more!

Our entire approach is going to be governed by this rule. With a bit of thought you should be able to see why this is so important. The last thing anyone wants is for an anonymous user to be able to modify the personal blog of a respected industry expert. This means that each type of user should have carefully controlled permissions that effectively block their ability to act outside the scope of their remit.

One upshot of this is that it is better to create a larger number of specific roles, rather than create a generic role or two, and allow everyone to use those catch-all permissions.

A role constitutes a number of permissions that define what actions any members of that role can and can't perform.

We will explore roles in detail in the next section!

Drupal gives us fine-grained control over what users can accomplish, and you should make good use of this facility. It may help to think of your access control using the following figure (this does not necessarily represent the actual roles on your site—it's just an example):

The shaded region represents the total number of permissions available for the site. Contained within this set are the various roles that exist either by default, like the Anonymous users role, or those you create in order to cater for the different types of users the site will require—in this case, the Blog Writer users and Forum Moderator users roles.

From the previous diagram you can see that the Anonymous users role has the smallest set of permissions because they have the smallest area of the total diagram. This set of permissions is totally encapsulated by the Forum Moderator users and Blog Writer users—meaning that forum moderators and blog writers can do everything an anonymous user does, and a whole lot more.

Remember, it is not compulsory that forum moderators encapsulate all the permissions of the anonymous users. You can assign any permissions to any role—it's just that in this context it makes sense that a forum moderator should be able to do everything an anonymous user can and more.

Of course, the blog writers have a slightly different remit. While they share some privileges in common with the forum administrators, they also have a few of their own. Your permissions as the primary or administrative user encompass the entire set, because there should be nothing that you cannot control.

It is up to you to decide which roles are best for the site, but before attempting this it is important to ask: What are roles and how are they used in the first place? To answer this question, let's take a look at the practical side of things in more detail.
Roles

It may seem a bit odd that we are not beginning a practical look at access control with a discussion on users. After all, it is all about what users can and cannot do! The problem with immediately talking about users is that the focus of a single user is too narrow, and we can learn far more about controlling access by taking a more broad view using roles. Once we have learned everything there is to know about roles, actually working with users becomes a trivial matter.

As mentioned, a user role in Drupal defines a set of rules that must be obeyed by all the users in that role. It may be helpful to think of a role as a character in a play. In a play, an actor must always be true to their character (in the same way a user must be faithful to their role in Drupal)—in other words, there is a defined way to behave and the character never deviates (no matter which actor portrays the character).

Creating a role in Drupal is very easy. Click the User management link under Administer and select the Roles tab to bring up the following:

As you can see, we have two roles already defined by default—the anonymous user and the authenticated user. It is not possible to change these, and so the Operations column is permanently set to locked. To begin with, the anonymous user (this is any user who is browsing the site without logging in) has very few permissions set, and you would more than likely want to keep it this way, despite the fact it is possible to give them any and all permissions.

Similarly, the authenticated user, by default, has only a few more permissions than the anonymous user, and it is also sensible to keep these to a minimum. We will see in a little while how to go about deciding who should have which permissions.

In order to add a new role, type in a name for the role and click Add role, and you're done. But what name do you want to add? That's the key question! If you are unsure about what name to use, then it is most likely you haven't defined the purpose of the role properly. To see how this is done, let's assume we require a forum moderator who will be a normal user in every way, except for the ability to work directly on the forums (to take some of the burden of responsibility off the administrator's hands) to create new topics, and to edit the content if necessary.

To get the ball rolling, type in forum moderator and click Add role—actually, you might even want to be more specific and use something like conservation forum moderator if there will be teams of forum moderators—you get the general idea.

Now the roles page should display the new role with the option to edit it, shown in the Operations column. Click edit role in order to change the name of the role or delete it completely. Alternatively, click edit permissions to deal with the permissions for this specific role (we discuss permissions in a moment so let's leave this for now).

Our work is just beginning, because now we need to grant or deny the various permissions that the forum moderator role will need in order to successfully fulfill its purpose. New roles are not given any permission at all to begin with—this makes sense, because the last thing we want is to create a role only to find that it has the same permissions as the administrative user.

Chances are you will need to add several roles depending on the needs of the site, so add at least a blogger user that can edit their own blog—we will need a few different types to play with later on.

Let's move on and take a look at how to flesh out this new role by setting permissions.

This article has been extracted from: Building Powerful and Robust Websites with Drupal 6
Building Powerful and Robust Websites with Drupal 6 Build your own professional blog, forum, portal or community website with Drupal 6

* Set up, configure, and deploy Drupal 6
* Design and implement your website's look and feel
* Easily add exciting and powerful features
* Promote, manage, and maintain your live website

For more information, please visit:
www.PacktPub.com/drupal-6-create-powerful-websites/book
Permissions

In order to work with permissions, click the Permissions link under User management and you should be presented with a screen much like the following (notice the new forum moderator role on the right-hand side of the page):

As you can see, this page lists all of the available permissions down the left-hand column and allows you to enable or disable that permission by checking or un-checking boxes in the relevant column. It is easy enough to see that one traverses the list, selecting those permissions required for each role. What is not so easy is actually determining what should and shouldn't be enabled in the first place.

Notice too that the permissions given in the list on the left-hand side pertain to specific modules. This means that if we change the site's setup by adding or removing modules, then we will also have to change the permissions on this page.

Most times a module is added, you will need to ensure that the permissions are set as required for that module, because by default no permissions are granted.

What else can we learn from the permissions page shown in the previous screenshot? Well, what does each permission precisely mean? There are quite a few verbs that allow for completely different actions. The following lists the more common, generic ones, although you might find one or two others crop up every now and then to cater for a specific module:

* administer: gives the user the ability to affect the function of a module. For example, granting administer rights to the locale module means that the user can add or remove languages, manage strings, and even export .po files. This permission should only ever be given to trusted users, and never to anonymous users.
* access: gives the user the ability to make use of a module without being able to affect it in any way. For example, granting access rights to the comment module allows a user to view comments without being able to delete, edit, or reply to them.
* create: gives the user the ability to create content of some sort. For example, granting rights to create stories allows users to do so, but does not also give them the ability to edit those stories.
* edit any/own: gives the user the ability to work with either anyone's content or specifically the content they have created—depending on whether edit any or edit own is selected. For example, granting edit own rights to the blog module means that the user can modify their own blogs at will.
* delete any/own: applies to content related modules such as Node and empowers users to remove either anyone's content or confine them to removing only content posted by themselves. For example, setting delete own blog entry allows users to take back any blog postings they may regret having published.

There are also other module-specific permissions available, and it is recommended that you play around and understand any new permission(s) you set.

Previously, assigning the edit own permission automatically provided the delete own permission. For added security, delete own permissions for individual core content types have been removed from all roles and should be assigned separately.

How do we go about setting up the required permissions for the forum moderator user? If we look down the list of permissions shown on the Permission page, we see the following forum-related options (at the moment, the forum moderator permissions are those in the outermost column):

Enabling these three options, and then testing out what new powers are made available, should quickly demonstrate that this is not quite what we want.

If you are wondering how to actually test this out, you need to create a new user and then assign them to the forum moderator role. The following section on Users explains how to create new users and administer them properly. Jump ahead quickly and check that out so that you have a new user to work with if you are unsure how it is done.

The following point might make your life a bit easier:

Use two browsers to test out your site. The demo site's development machine has IE and Firefox. Keep one browser for the administrator and the other for anonymous or other users in order to test out changes. This will save you from having to log in and log out whenever testing new permissions.

When testing out the new permissions one way or another, you will find that the forum moderator can access and work with all of the forums—assuming you have created any.

However, notice that there are node module permissions available, which is quite interesting because most content in Drupal is actually a node. How will this affect the forum moderator? Disable the forum module permissions for the forum moderator user and then enable all the node options for the authenticated user before saving and logging out.

Log back in as the forum administrator and it will be clear that despite having revoked the forum based options for this user, it is possible to post to or edit anything in the forum quite easily by selecting the Create content link in the main menu. Is this what you expected?

It should be precisely what you expect because the forum moderator is an authenticated user, so they have acquired the permissions that came from the authenticated user. In addition, the forum posts are all nodes, and any authenticated user can add and edit nodes, so even though the forum moderator is not explicitly allowed to work with forums, through generic node permissions we get the same result:

Defined roles are given the authenticated user permissions.

Actually, the result is not entirely the same because the forum moderator can now also configure all the different types of content on the site, as well as edit any type of content including other people's blogs. This is most certainly undesirable, so log back in as the primary user and remove the node permissions (except the first one) from the authenticated user role. With that done, you can now spend some time building a fairly powerful and comprehensive role-based access control plan.

As an addendum, you might find that despite having a goodly amount of control over who does what, there are some things that are not easily done without help from elsewhere.
Users

A single user account can be given as many or as few permissions as you like via the use of roles. Drupal users are not really anything unless they already have a role that defines the manner in which they can operate within the Drupal framework. Hence, we discussed roles first.

Users can be created in two ways. The most common way is by registering on the site—if you haven't already, go ahead and register a new user on your site by clicking the Create new account link on the homepage just to test things out. Remember to supply a valid email address otherwise you won't be able to sign in properly. This will create an authenticated user, with any and all permissions that have been assigned to the authenticated user role.

The second way is to use the administrative user to create a new user. In order to do so, log on as the administrative user and click on Users in User management under Administer. Select the Add user tab and follow the instructions on that page. For example, I created a new forum moderator user by ensuring that the relevant role was checked:

You will need to supply Drupal with usernames, email addresses, and passwords. Once there are a couple of users to play around with, it's time to begin working with them.

This article has been extracted from: Building Powerful and Robust Websites with Drupal 6
Building Powerful and Robust Websites with Drupal 6 Build your own professional blog, forum, portal or community website with Drupal 6

* Set up, configure, and deploy Drupal 6
* Design and implement your website's look and feel
* Easily add exciting and powerful features
* Promote, manage, and maintain your live website

For more information, please visit:
www.PacktPub.com/drupal-6-create-powerful-websites/book
Administering Users

The site's administrator is given complete access to the other users' account information. By clicking on the edit link shown to the right of each user account (under the Operations column heading) in the Users page under User management, it is possible to make any changes you require to a given user.

Before we do though, it's worth noting that the administration page itself is fairly powerful in terms of being able to administer individual users or groups of users with relative ease:

The upper box, Show only users where, allows you to specify several filter conditions to cut down the result set and make it more manageable. This will become more and more important as the site accumulates more and more users. Once the various filter options have been implemented, the Update options allow you to apply whatever changes are needed to the list of users selected (by checking the relevant checkbox next to their name).

Having both broad, sweeping powers as well as fine-grained control over users is one of the most valuable facilities provided by Drupal, and you will no doubt become very familiar with this page in due course.

Click on the edit link next to the forum moderator user and take a look at the Roles section. Notice that it is now possible to stipulate which roles this user belongs to. At present there are only two new roles to be assigned (yours might vary depending on which roles have been created on your setup):

Whenever a user is added to another role, they obtain the combined permissions of these roles. With this in mind, you should go about delegating roles in the following fashion:

1. Define the most basic user of the site by setting the anonymous user permissions.
2. Set permissions for a basic authenticated user (i.e. any Tom, Dick or Harry that registers on your site).
3. Create special roles by only adding the specific additional permissions that are required by that role, and no more. Don't re-assign permissions that the authenticated user already has.
4. Create new users by combining whatever roles are required for their duties or needs.



If you follow the steps above, you will be sure to always give the correct permissions to each role by avoiding redundancy and only applying permissions incrementally by role. Basically, you are building up a user's permissions from the most basic to the most complex without having to assign every single permission each time. It should be commonsense (although not a technical obligation) that a forum moderator would have all the permissions of an anonymous and authenticated user, plus a few more. Looking back to the first diagram in the section Planning an Access Policy you can see that, in this case, we would:

1. Define the anonymous user and authenticated user role permissions—an authenticated user should have all the permissions of an anonymous user, plus whatever else is needed by a basic site user.
2. Create new roles with only the additional permissions needed for both the forum moderator and blog user respectively—other than those given to the authenticated user.
3. Assign blog writers to the blog user role (they are automatically given the permissions granted to an authenticated user), and do the same for forum moderators and their role.

Other than using that strategy for assigning roles to users, the rest, as they say, is history. Play around with any new roles you create to ensure they behave as you expect and then move on.
User Settings

This section looks at how the site treats users, rather than discussing what users can and cannot do. However, you will find that some of the information in this section is important for the look and feel of the site.

Click on User settings under the User management. The following set of options is provided, beginning with user registration settings, as follows:

You might want to consider which of the first three options to select quite carefully, depending on how you envisage the site functioning. For example, allowing everyone to read and post comments to the forums, or do whatever, without needing to register first may be ideal. If this is the case, then it is likely that the only people who would need to register are going to be performing some sort of administrative duties, in which case you would probably want to select the first option, or at least the third option.

If you do go for the third option, then check the user list regularly in order to unblock new users as soon as possible. Note that Drupal can be configured to email the site administrator automatically whenever there is a new user registration application.



Additionally, if you enter a message into the User registration guidelines text area then this will appear during the registration process, as shown in the following screenshot:



I specifically added this note in here because it is fairly well known that new users often log in with the one-time password generated by Drupal, but then fail to add their own password before logging off. When they return, they are then locked out because the one-time password has expired and there is no new one set.

The next section on this page deals with the process of user email customization for the various different type of emails that Drupal sends out. There is an interesting facet to this in that Drupal makes certain variables available for use within the static text that is entered. Let's take a look at how to modify a line or so in order to get the feel for how it works.

By way of example, we will change the Welcome, no approval text from:

Account details for !username at !site

to a slightly sprightlier:

Congratulations !username, you have registered with the !site on !date!

Nothing too complicated here! The keywords preceded by the ! sign are simply placeholders for other values that are inserted into the email, according to how they are set at that particular time. This gives you the ability to personalize correspondence. In this case, the subject of the welcome email for a user registered as David M is now displayed as follows:



The !username, !site, and !date placeholders have been correctly changed to reflect the contents of the variables for that particular setup. There are settings available for several standard emails such as password recovery and welcome (awaiting admin approval). The defaults are fairly sensible and easy to change should you need to. Remember the placeholders that are available for each piece of text are mentioned below the section heading, so play around with them until you are comfortable with their usage:



The final two sections deal with Signatures and Pictures. If you wish to enable Picture support for users, then select Enabled from the list, provide a default picture (if you want one), and click Save configuration (the other settings are fairly self explanatory and sensible, and you can come back at any stage to change them if they are not suitable).

Drupal will set up a pictures folder to hold all of the pictures within the files folder in your Drupal installation. Once everything is done, users will have a new section added to the edit tab of their my account page, like the following figure:



When the picture has been successfully uploaded, it will appear on the my account page, and with the user's blog and forum posts on the site. If the image does not appear and you end up seeing a link, something like the following:



...then you will need to ensure that you set the correct upload module permissions on the Permissions page, as follows:



Remember that since the forum administrator user automatically receives all the permissions of the authenticated user, it is not necessary to enable the view uploaded files permission for the forum administrator as this would be redundant and would make the purpose of your user less clear.

It is possible to control where the user pictures are displayed by selecting the Configure tab of the Themes page under Site building and checking the relevant picture related checkboxes, as shown in the following figure:



Allowing users to incorporate pictures into a site is a good way for people to be able to personalize their contributions, and also gives everyone something visual to associate posts with. This is a great way to foster a community, as it helps give different users an identity of sorts.

Changing the picture is easy! Simply modify it in the Picture section of the user's edit page, as shown in the following screenshot:



That is pretty much the end of the line for configuring users. There are still a few more things we need to discuss with regards to security before we can move on though.
Access Rules

So far it should seem like Drupal has things more or less covered when it comes to ensuring that it is possible to control who does what on the site. This is certainly the case, but there are a few more situations that we have not yet discussed, and may well end up affecting the site at some stage. For example, what happens if there is a company that repeatedly spams your forums with advertisements and marketing information? Or, what happens if only people from a certain company should have access to your site?

Problems of this nature can really be a thorn in the side. Access problems can even end up driving community members away—unless you have the ability to set access rules.

There are some techniques that can be used to set access rules via the Access rules link under User management. To implement any access rules you will need to select the Add rule option, which brings up the following page:



From this you can see that I am in the process of making a rule that denies access based on an email address—more specifically, really@nastyspammer.com. Before we continue on this line, it is important to note that there are both Allow and Deny options available, and these will act based on a supplied Username, E-mail, or Host address given in the Rule type section. The final option, Mask, allows you to specify the actual name of the user or host to which the rule will apply.

In the above case, the email address really@nastyspammer.com will have a deny rule created after Add rule has been clicked.

Go ahead and create a rule like this one, and notice that the rule now appears under the list tab. Now that there is a deny rule in place, how do we go about using it? The answer is that it is already being used. If someone tries to register with the email address supplied in the rule, they will be denied access. As it stands, this is probably not very helpful, because it is unlikely you will know ahead of time what specific email addresses to block.

In order to cater for the times when you aren't entirely sure of the specific address, there are two wildcard characters provided that can serve as generic strings or characters. Imagine you wanted to ban someone who runs a small spamming business. Simply blocking their current email address is not really sufficient, because they can easily create another address and use that one to register. If you know that the addresses come from one location, such as:

@irritating_spammer.com

...you could use the % character to match whatever characters are present before the @ sign, effectively stopping anyone from that email server from registering, like so:

%@irritating_spammer.com

If you have a Hotmail account, or something similar, try blocking any address that ends with @hotmail.com and then attempt to register an account on the site. Drupal will dutifully display the following message:



A new problem rears its ugly head when it so happens that you don't want to allow Hotmail addresses on the site, with the exception of a close personal friend who is traveling around the world and can only access Hotmail addresses. In this case, you need to set an Allow rule as well. If, for example, the email address of the person is good_friend@hotmail.com, then you could set the Allow rule by selecting the appropriate options to cater for this on the add rule page.

The rules would then look something like the following:



What this does is ban all Hotmail addresses from the site. However, because an allow rule takes precedence over a deny rule, the one and only Hotmail address specified in the single allow rule shown in the screenshot will work fine. Now when your good friend attempts to register, everything will go swimmingly well.

After adding plenty of rules, things can sometimes become slightly confusing and it is simply not feasible to continue attempting to register new names all the time, to ensure that they work according to plan. In this case, use the Check rules tab on the right-hand side of the Access rules page. This allows names of users, email addresses, and hosts to be entered in order to check whether they have access or not. Simply compare these results with your expectations to determine if everything is working as planned.

One final thing to bear in mind is that if you deny access using the host criteria, then this will be enforced throughout the site and not just on the registration pages. For the case of the spammer, you would probably want to deny access to the site in general; so you would select the host option with something like this for the Mask:

%irritating_spammer%

This would then match to any host with irritating_spammer in it. For example:

www.really_irritating_spammer.com
www.mildly_irritating_spammer.com
www.extremelyirritating_spammer.org
www.unbelievably_irritating_spammer.comms.org.co.sz

...and so on.

It is important to realize that this only applies to the host criteria:

If an undesirable user has already registered with an email address that is subsequently blocked, then no action will be taken against them.

Remember to check that all the added rules have the desired effect on the site's access policy. It would be a shame to make a rule that prevented potentially valuable community members from accessing content, causing them to go elsewhere.

I would be remiss if I didn't mention, before finishing off, that there are a number of other user access/authentication-related modules available on the Drupal website. It is probably worthwhile to check these out at http://drupal.org/project/Modules/category/74 in case there is something that is particularly suited to your needs.
Summary

This article provided a good grounding in the basics of controlling access to your site's content. Drupal comes with a large number of facilities and options to ensure proper maintenance of the site by retaining overall control with the administrative user, as well as delegating important jobs to trusted users via the use of roles.

We looked at how to go about planning an access policy. This is not only an important requirement, in terms of making sure the site runs smoothly, but also helps to solidify how the site will eventually work by forcing you to consider many eventualities. A tour of the fundamental aspects of access control in Drupal saw us discussing roles, permissions, and users, and learning how to plan and implement an access policy based on the requirements of the site.

Access rules were then introduced as a further way of controlling who gets into the site, with a discussion on how to use the wildcard characters effectively. Planning, and above all, testing, will help ensure that everything works as intended.

With that, we are done with access control, although you are strongly urged to spend some time playing around with the various options until you are comfortable with being able to make changes and understanding their effects.

About the Author

David Mercer was born in August 1976 in Harare, Zimbabwe. Having always had a strong interest in science, David came into regular contact with computers at university where he graduated cum laude with majors in applied math and math (although he minored in computer science).

As a programmer and professional writer who has been writing both code and books for about nine years, he has worked on a number of well known titles, in various capacities, on a wide variety of topics. His books have sold tens of thousands of copies and have been translated into over 6 different languages to date.

David finds that the challenges arising from the dichotomous relationship between the science (and art) of software programming and the art (and science) of writing is what keeps his interest in producing books piqued. He will no doubt continue to write professionally in the future.

David balances his time between programming, reviewing, writing, and contributing to interesting web-based projects such as RankTracer and LinkDoozer. When he isn't working (which isn't that often) he enjoys playing guitar (generally on stage and unrehearsed) and getting involved in outdoor activities ranging from touch rugby and golf to water skiing and snowboarding. Visit RankTracer or find him on LinkDoozer where he is generally lurking.

Thursday, April 10, 2008

HP ships USB sticks with malware

Posted on ZDNet News: Apr 9, 2008 5:02:00 PM
Hewlett-Packard has released a batch of USB keys for numerous Proliant server models which contain malware that could allow an attacker to take over an infected system.

The worms contained on the 256KB and 1GB USB drives have been identified as W32.Fakerecy and W32.SillyFDC. The worms spread by copying themselves to removable or mapped drives and affect systems running Windows 98, Windows 95, Windows XP, Windows Me, Windows NT and Windows 2000, according to AusCERT.

HP's Software Security Response Team issued a warning to AusCERT this week after discovering the worms on the USB drives and has also provided a list of affected servers to the security response organization.

To find out whether a drive is infected, HP recommends inserting it into a system with up-to-date antivirus software. Systems with up-to-date antivirus should be protected from the threat, according to HP.

John Bambenek, a researcher at the security organization Sans Internet Storm Center, has said that because the infected USBs only affect Proliant servers, a targeted attack cannot be ruled out.

However, the threat risk from the worms is considered to be low. "This is probably not going to escalate into a widepread epidemic," Nishad Herath, senior research scientist at McAfee Avert Labs, told ZDNet.com.au. "But I would most definitely urge users to perform a virus scan of any media--including any new blank drives--you receive from vendors prior to installing/using them as slip-ups like this have been known to happen in the past."

HP claims the worm-infected USBs will have only affected a small number of customers.

"HP takes all quality issues very seriously. Because the keys involved are used to install optional floppy-disk drives, this only affects the USB Floppy Drive Key kit which is a very low volume option and impacts a very small percentage of our ProLiant customer base. We've determined root cause and are fully confident that we have resolved this event. To date, no customers have reported this issue," a spokesperson for HP told ZDNet.com.au.

HP has provided an advisory page for customers with affected USB keys.

To find out whether a drive is infected, HP recommends inserting it into a system with up-to-date antivirus software. Systems with up-to-date antivirus should be protected from the threat, according to HP.

John Bambenek, a researcher at the security organization Sans Internet Storm Center, has said that because the infected USBs only affect Proliant servers, a targeted attack cannot be ruled out.

Liam Tung of ZDNet Australia reported from Sydney.

Tuesday, April 8, 2008

Time Machine via AirPort Disk Is Unsupported, Apple Says

by Glenn Fleishman

Apple confirmed for me last week that a feature for using hard drives attached via USB to an AirPort Extreme Base Station is an unsupported feature. The company declined to provide further information. This feature was available in the betas of Mac OS X 10.5 Leopard, as has been widely reported, but was removed from the public Leopard feature list and from the shipping version of the operating system. Apple had been working on providing me a definitive statement since my review of Time Capsule for Macworld was published on 21-Mar-08.

What a "lack of support" means is that if you attempt to use an 802.11n AirPort Extreme Base Station for Time Machine backup, you won't get any help from Apple's technical support, something that readers have already told me. I've been receiving reports that USB-attached drives work erratically with an AirPort Extreme. TidBITS editor Joe Kissell and I have been discussing the strange array of scenarios in which you find an Apple Filing Protocol (AFP) volume that's shared by the AirPort Extreme server not appearing automatically for Time Machine. (See "MacVoices Podcast Covers Time Capsule Ins and Outs," 2008-04-03, for links to the podcasts. I also talked about Time Capsule and this problem in a podcast on 26-Mar-08 with Jason Snell, editorial director for Macworld.)

This option to choose an AirPort Extreme-connected drive first appeared with the release of several related firmware, driver, and operating system updates on 19-Mar-08 (see "AirPort Update Extends Time Capsule, Adds AirDisk Support," 2008-03-19). I speculated at the time that this addition was an error on Apple's part, perhaps due to a debugging feature left turned on that wasn't properly turned off before the updates shipped. This was buttressed in part by the way in which Time Capsule drives - whether an internal drive or ones connected externally via USB - appear via Bonjour in a list of selectable volumes when setting up Time Machine, but AirPort Extreme disks do not.

For more background on this situation, see the original response I had in "Time Capsule and Its Associated Rage Factor, 2008-01-17" and details on Time Capsule's USB drive support in "Time Capsule Ships with Support for USB Drive Backups," 2008-02-29.

Somewhere along the line, Apple changed the name of this concept of sharing drives from USB over the network from "AirDisks" to "AirPort Disks."

Apple says Final Cut Server shipping after lengthy delay

By AppleInsider Staff
Published: 08:00 AM EST

Apple on Tuesday announced that Final Cut Server, its new software solution for media asset management and workflow automation announced last year, is finally shipping to customers.

Introduced last April at the 2007 National Association of Broadcasters conference, Final Cut Server is a scaleable server application that automatically catalogs large collections of assets, allowing searching across multiple disks and SAN volumes, as well as viewing, annotation and approval of content from anywhere using a PC or Mac.

"Whether producing a 30-second spot, the nightly news or a major motion picture, Final Cut Studio is the choice of editors around the world," said Rob Schoeben, Apple's vice president of Applications Product Marketing. "With the introduction of Final Cut Server, collaboration just got a whole lot easier for millions of editors, producers and clients who work with Final Cut Studio."

Final Cut Server automatically catalogs media and generates thumbnails, poster frames and low-resolution clip proxies for quick browsing in user specified formats. A cross-platform client enables a PC or Mac to use Final Cut Server's broad search capabilities, which extend from simple keywords to complex combinations of IPTC, XMP and XML metadata. Final Cut Server also configures a range of highly specific access controls that define user permissions on an asset or project basis.

Apple says the application can scale to support workgroups of different sizes, ranging from a two-person post house to a multi-national news organization and can automate as much, or as little, of the production pipeline as needed. A configurable event-based response model tracks job status, monitors media changes, and automates review and approval notifications and complex sequences of tasks-all through a series of simple menu selections.



Tightly integrated with Final Cut Studio for a seamless extension of the workflow, Final Cut Server includes Compressor 3, Apple's industrial strength digital encoding and compression tool, which delivers pristine format conversions for publishing to DVD, broadcast television, the Internet, Apple TV, iPod, iPhone and other mobile phones.

Final Cut Server is available immediately through the Apple Store, Apple's retail stores and Apple Authorized Resellers for a suggested retail price of $999 for one server and 10 concurrent client licenses, and $1,999 for one server and unlimited client licenses. Full system requirements and more information on Final Cut Server can be found here

Apple notebook lines to see major design changes, sources say

By Kasper Jade
Published: 12:35 PM EST

Apple Inc.'s existing MacBook and MacBook Pro notebooks will be the last of their breed, as both product families are destined for major design changes upon their next refresh, AppleInsider has learned.

Of the two, the 13-inch consumer MacBooks will undergo the most significant metamorphosis, shedding their plastic enclosures for ones constructed from more eco-friendly materials such as aircraft-grade aluminum and stainless steel, people familiar with the matter say.

The move, which makes good on a promise by company chief executive Steve Jobs to push towards a "greener Apple," will also mark an end to Macs that come clad in the now tawdry looking white enclosures that began with front face of original iMac nearly a decade ago.

Similarly, the MacBook Pro is also bound for aesthetic revisions, which like their upcoming MacBook counterparts are described by those familiar with the products as borrowing several design cues from the August 2007 aluminum iMacs and all-new MacBook Air. The end result, those same people say, will be a more uniform Mac product matrix in terms of design and material usage, and a MacBook offering that will far outclass its rivals.

Though precise details are admittedly limited given the ongoing revision process, it's presumed this will include instances of matte black on portions of the casings, oversized trackpads, and the adoption of the MacBook Air's keyboard by the MacBook.

While the footprint of the 13-, 15-, and 17-inch systems will remain largely unchanged, Apple will reportedly be free to perform some trimming around the edges, similar to -- but nowhere near the same magnitude -- as what was accomplished with the MacBook Air, and to a lesser extent, the rear of the aluminum iMacs.

Compelling the Cupertino-based firm to introduce radical revisions across its notebook lines at this juncture are two primary factors. The first is the company's industrial design cycle, which typically spans 18-24 months.

Neither the MacBook nor MacBook Pro have undergone an aesthetic or structural revision since adopting Intel chips back in the first half of 2006, meaning both will sport outdated outfits by Apple's design standards come mid-year.

The design of the MacBook Pro is particularly dated, having been introduced in January of that year with a form factor largely reminiscent of the late PowerBook G4, only 20 percent slimmer. MacBooks, arguably the fresher of the two lines, saw the most significant overhaul of all Intel-bound Macs systems just a few months later with their robust, magnetic-latching enclosures. (AppleInsider provided coverage and details of both design revisions (MacBook Pro: 1, 2; MacBook: 1, 2, 3, 4, 5) in the months leading up to their respective introductions.)

Also paving the way for redesigned enclosures at this time are logic-board changes on the part of Intel that offer Apple the opportunity to re-asses and slightly modify the notebooks' internals. Both the MacBook and MacBook Pro are to receive "Montevina"-based processors from the chipmaker's upcoming Centrino 2 platform, which require a new "Socket B" logic-board. The second-gen mobile Penryn chips will boast a 1066MHz front-side bus and clock between 2.26GHz and 2.8GHz.



Intel's roadmap calls for Montevina to splash down this June, around the same time Apple will host its annual developers conference in San Francisco. However, it's unclear at this time whether the Mac maker will use that forum to showcase its new notebook designs, or reserve their unveiling for a different stage at a slightly later date.

Although Apple has been amongst the first PC manufacturers to adopt Intel's latest mobile technologies over the past two years, there's often a window period of several weeks (or months) between the chipmaker's formal announcements and the arrival of supporting Mac systems. Therefore, it's believed volume shipments of Montevina-based Mac notebooks won't take place until sometime during the third calendar quarter of the year, which spans July through Sept.

Nevertheless, Apple has been on a tear as of late when it comes to notebook sales momentum, and the new models are only expected to accelerate that growth. According to the most recent data from research firm NPD, sales of Mac notebook systems in the US retail sector rose 64 percent year-over-year for the month of February, compared to an average 20 percent increase for the rest of the industry.

While awaiting new MacBooks and MacBook Pros in the third quarter, Apple enthusiasts will have a pair of other major product launches to anticipate. First and foremost will be a complete refresh of the company's desktop computer families, which will include iMac and Mac mini systems built around current generation Core 2 Duo mobile processors based on Intel's Penryn architecture.

Also expected within the next 60 days is an eagerly anticipated update to the company's iPhone handset that will operate on third-generation wireless networks, which promise speed increases of up to 10X for Internet-related functions.

DCR Workshop: Color Management, Part I

Submitted by David Rasnake on Thursday, April 03, 2008

Anyone who's done much image post-processing knows it's true: what you see on your screen doesn't always tell you much about how something's going to look in print. If you've ever fine-tuned a photo in Photoshop only to be disappointed when the printed results didn't even come close to the power and punch of the shot on your screen, the importance of having your monitor's output match your printer's is probably evident. While full-time pros recognize the need to be able to accurately control color from one end of their workflow (the camera) to the other (the print) and through all the stops in between (the computer), this idea has only recently come into its own with hobbyist photographers, fueled to some degree by the availability of lower cost color management tools.



If you've been scared off of color management in the past by the mystique that surrounds it, fear not: with the current crop of hardware and software color management tools, especially, calibrating and profiling your workflow is not only manageable but even downright easy, even for profiling newbies. In this first installment of a two-part DCR Workshop series, we'll move through calibrating and profiling your display – the process of standardizing your monitor's output that forms the foundation of making what you see on screen what you get when you print your images: why is it important, how does it work, and what do you need to make it happen? In an overview that's part tutorial, part product review, we'll also demo the display profiling process using a particular color management tool – in this case, Datacolor's Spyder3 Elite system.

WHY CALIBRATE AND PROFILE?

Admittedly, for casual photographers carefully controlled color may not be the most photographically effective use of time and money. For basic calibration solutions, if you're working on a Macintosh try the built-in calibration utility in OS X's display controller; on a PC, Adobe Gamma performs a similar function, though you have to have Photoshop installed to use it (and don't forget to disable/remove it if you move up to a third-party calibration/profiling system). For many users, these basic correctives may well be enough to get your display close enough to what you're getting from your preferred photo output method – whether it's your home printer or a photo lab.

What happens, though, when "close enough" isn't close enough? Getting the perfect look on your screen after hours of editing only to spend countless more hours trying to get a print that aligns with what you're seeing is one of the most frustrating aspects of digital photography. Often, the differences that we're talking about at this level are subtle (they certainly were in our testing), but if they aren't usually the difference between a bad print and a good one, they can easily constitute the minutia that separates good prints from great ones. Given the wide variance we experienced in comparing color on one monitor to the next, it's probably safe to say that a fair number of DSLR users have spent more time and money on camera-side equipment upgrades that will make a less apparent impact on the final printed image than a calibrated display and profiled print workflow.

While advanced display calibration isn't a "magic bullet" for color and tonal range issues – there's output device profiling to consider, for starters, and even the best calibration systems can't fully account for hardware and image handling differences – it's an important first step in making what you're seeing when you edit photos a reproducible situation across a range of devices. With display calibration and profiling, what you're ultimately doing is bringing what you're seeing on a specific monitor – in terms of color, brightness, and contrast – into line with a widely accepted standard for image reproduction, and in this sense, calibration is an investment in peace of mind. With a calibrated and profiled display, you have some assurance that what you see on-screen is, up to a pretty tightly defined standard, what you should expect to get in print, taking a lot of the guesswork about how something will print up out of the image workflow.

I'll repeat that for novice shooters looking to get decent, consistent snapshot prints, a color management system like the one described in the sections that follow may well be overkill. But if you're running up against colors that just won't cooperate from one side of your workflow to the other, keep reading...

CALIBRATION AND PROFILING: NUTS AND BOLTS

Once you're sold on the idea of display calibration and profiling, it's time to get down to the actual process of calibrating a display. Anyone who has attempted to understand calibration and profiling before is probably aware that this is where things get technical (and, in many cases, more than a little obtuse), and those of us without advanced degrees in physics start getting scared. In calibrating and profiling a display, however, there are only a few basic concepts at work, and before we jump into the calibration process itself, a little demystification is in order.

Calibration and Profiling: What's the Difference?

First, a quick note on the fundamental terms themselves, as the words "calibration" and "profiling" are not interchangeable. At its most basic, "calibration" has to do with setting a monitor's brightness and contrast to accepted standards. A "profile" stores the information needed to bring the display into calibration, along with information used to correct how the monitor displays color. To use the technical terms, calibration (the first step) focuses primarily on adjusting gamma, white point, and luminance, while profiling (which happens after the display is calibrated) stores this calibration information and also adjusts the monitor's gamut. If these terms mean nothing to you, don't worry: we'll move through them step by step.

Understanding Gamma

Correcting a display's "gamma" is probably the most talked about, and least understood, part of the calibration process. In order to ensure that what you see is what you get, it's also potentially the most important. In essence, "gamma" refers to the contrast curve of your monitor; it doesn't effect the maximum values (pure white and pure black), but rather, changes the way the tones between these two extremes relate to each other. If you've ever played with the contrast of an image, you can probably visualize this basic concept:


Normal Contrast


Increased Contrast

As I increase the contrast on this image (I've used a black and white to make the tonal changes easier to see), the very lightest and very darkest areas of the image are still just as they were before. What has changed, however, are the gray values in the middle of the range, with the darker grays "moving" closer to pure black, and the lighter grays "moving" closer to pure white. To oversimplify somewhat, your display's gamma refers to how much of this kind of mid-tone shifting contrast it applies to what's being displayed.

LUTs and Profiles

The final displayed gamma is the result of both the monitor's contrast tendencies and information supplied to the display by the graphics card through a system known as the look-up table, or LUT. Now that you know this acronym, you can probably let it pass immediately from your mind – unless you have an older graphics card or you get into much more advanced profiling, the user and the LUT have no direct interaction, and each need only trust that the other exists and is doing its job and leave it at that. In the interest of full disclosure, though, the final word on this topic is that in calibrating a monitor, you are essentially supplying data through the means of a utility or piece of software to the LUT, which compensates for the display's contrast tendencies to arrive at the chosen contrast level – the chosen gamma.

Along with color rendering information, this calibration data forms the "profile" that the computer uses to bring the display into conformity with the standards you select. More on this a little later on.

Gamma and White Point, Mathematically

Where an actual display is concerned, gamma isn't just a general concept but a specific, expressed number value – normally between 1.0 and about 2.5 (though it can theoretically be higher). These numbers come from the mathematical representation of a particular contrast curve – if you've ever used the "Curves" function in Photoshop or similar programs to manipulate image contrast, this idea will be familiar. (For tech heads who insist on knowing more, gamma, or γ, is the exponent in an equation f(x)=xγ relating display intensity, x, and luminance, f(x). In terms of actually calibrating a monitor, this specific piece of knowledge is completely superfluous as well.)

Obviously, then, a purely linear curve (one that applies, for purposes of the contrast analogy, no contrast adjustment to the display) has a value of 1.0, with values greater than 1.0 increasing the amount of contrast, in effect. With many calibration utilities, you can calibrate your gamma to whatever value you'd like, but these days a gamma of 2.2 is the accepted standard for most uses. Thus, if you're using one of these color calibration utility that allows you to set gamma – whether a third-party system, an Adobe or Apple utility, or your graphics card's control panel – use 2.2 as a starting point.

Similarly, monitor calibration must also take the device's displayed "white point" into account. Anyone who's familiar with digicam white balance can probably foresee where this related concept is heading: white point is, for all intents and purposes, the color temperature of the image. While the choice of white point (which is, like white balance, defined as a temperature value in degrees Kelvin) for your display is somewhat arbitrary, the accepted standard is 6500K – essentially, the color temperature of mid-day daylight.

Why Does it Matter?

So why these standards for gamma and white point, and why do they matter? Basically, the human eye doesn't see the world in a linear way, and a contrast curve with a gamma of 2.2 provides a nice match for the way our eyes see: calibrating a monitor to a gamma of 2.2 helps make the display's color space better align with the way we see the world. It's all more complicated than that in truth, and there are other accepted gamma standards for different uses, but if you're a Windows user, especially, with a typical monitor working in the sRGB color space – the default setting for most cameras, if they have a setting at all – 2.2 is the most commonly accepted choice.

Likewise, calibrating the white point on your monitor to 6500K gives you, in most basic terms, a picture of what your printed images should look like under daylight-colored lighting (though as we'll see, calibration utilities sometimes recommend a different white point to account for ambient light conditions in your work environment).

Ultimately, a corrected gamma and white point, along with appropriately set brightness (which establishes the pure white and pure black points in which the contrast curve operates), form the basis of monitor calibration, allowing you to distinguish subtle changes in shading.

Gamma

With a calibrated monitor, you should be able to view a series of stepped "gray percentage" blocks like the ones above and make out the distinctions between each segment. If you can't, your display isn't showing you everything that's potentially going on within your images.

Gamut and Profiling

As noted, the calibration data used to set your monitor's displayed gamma to 2.2 and white point to 6500K is a large part of the profile that your chosen calibration software or utility adds to your machine. The profile (technically known as an "ICC profile") is nothing more than a file that stores data used by your graphics card to adjust your display output to conform to the standards used in the calibration process. In short, the profile is used by your graphics card to tell the display what to do to achieve correct gamma and white point. It's also crucial to the other piece of the profiling equation: gamut.

Not to be confused with gamma, "gamut" refers to the range of colors your monitor is capable of displaying. In addition to correcting gamma and white point to specified standards, a color management system also analyzes the monitor's output gamut and compares the colors it displays with known values. If your monitor oversaturates certain greens, for instance, a profile can zero in on these specific color values and apply a corrective via your graphics card.

Building a color profile is where visual calibration becomes too subjective to be of much use. While you can usually get gamma calibrated to an acceptable standard, for dealing with your display's color reproduction issues, a third-party system using a colorimeter is really almost a must.

CHOOSING AND USING COLOR MANAGEMENT TOOLS

Thankfully, understanding the intricacies of what color management tools are doing is much more difficult than actually using one. When it comes to consumer-level hardware and software packages for calibrating and profiling your display, it's really a two-horse race. For this tutorial and test, we went with Datacolor's Spyder3 Elite system, though the somewhat more dominant X-Rite (to use another analogy, the Canon to Datacolor's Nikon) has several interesting tools out there with similar functionality.

For casual users, the Spyder3 Elite system (at around $270) comes off as a bit pricey, though advanced photographers will appreciate the more open features set it provides over previous and current step-down Spyder models. Given the level of customizability and the decent amount of power it offers, it's a relative bargain compared to a commercial spectro system. Still, for users looking to wade into the monitor calibration pool rather than dive in head-first, both X-Rite and Datacolor offer more basic monitor calibration and profiling systems in the $150 range.

The walk-through that follows, then, deals specifically with the Spyder3 Elite system, though the process is much the same whatever hardware and software package you choose.

The Tools for the Job

Whatever company you go with and whichever system you choose, if you're shopping in the consumer and entry-pro level markets that the devices mentioned previously cover, what you're buying is essentially a two-part apparatus. The primary (really the only) piece of hardware needed is a colorimeter – a small USB device used to measure and evaluate the output of your display and communicate this information back to the computer.



The latest, greatest technology for consumer colorimeters is a built-in ambient light measurement system (that little "eye" on the front of the device), though the business end of the colorimeter is the sensor found on the flipside.



In Datacolor's lineup, at least, it's the software package – the second part of our two-part system – that defines the setup (all of the consumer-level Spyder systems use the same colorimeter). As noted, we gave the Spyder3 Elite system a run, though Datacolor's Spyder3Pro software does much of the same thing without a few of the custom functions and bells and whistles.

Installing the Software

The entire process of installing Datacolor's software, connecting the Spyder, answering some questions, and letting the device build a profile took less than ten minutes, start to finish. If you're feeling impatient, a quick video walk-through shows how it's done:



To get things rolling, we dropped the Spyder3 Elite CD into the drive (in the case of the photos and video, on my workhorse Dell business notebook) and clicked "Install" from the pop-up menu.



On a PC, the Spyder3 utility loads a standard installer screen and goes to work. Everything was finished in less than three minutes, and with no restart required I plugged my colorimeter in via its USB connection was ready to calibrate. (Just for the sake of comparison, we also tried out the installation on four other machines – desktops and notebooks – including an iBook G4, with similar results and no installation glitches all around; if anything, the interface is a little cleaner, and the software runs a little smoother in a Macintosh environment.)

Launching the Spyder3 Elite utility for the first time, the system immediately detects an unprofiled display and automatically loads the "New Monitor" window.



Select the checkbox for "Calibrate this display," click "Next," and you're off and running.

Screen Settings and Options

At this point, the user is called on to provide some information about the display being calibrated/profiled, and to make some baseline hardware adjustments to get the monitor ready for the software's process. The Spyder's first question should be obvious: what kind of display are we dealing with?



In reading down the list of options, you'll note that the Spyder3 Elite system even allows calibration and profiling of projectors, ensuring color control for slideshows and presentations. While most casual users will likely be indifferent to this feature, for pros and other serious shooters looking to show off their work in a larger setting, it's a neat addition to the package. As interested as I was to see how the process for a projector might actually work – this is where the tripod socket on the bottom of the Spyder's stand apparently comes in handy – I selected "Laptop" as my display type (note that it's separate from "LCD," for reasons that will become obvious momentarily).

The next order of business involves specifying the level of hardware-side control your particular display provides.



Depending on the display type selected, the list of options is tailored to cover the common range of adjustments (a second screen covers the RGB and Kelvin sliders found on many newer LCD displays, for instance). In this case, my tester laptop has only backlight adjustment.

Once you've selected the hardware-side adjustments that can be made, the software walks you through what to do with them. In my case, the backlight control was used to visually set the white luminance, based on a quick visual analysis of a series of stepped gray blocks like the ones mentioned earlier.



For displays with more controls, Spyder3 Elite may prompt you to restore some to their default settings, or to use others to optimize your display output. Whatever the specifics, however, the software's instructions are, in most cases, reasonably clear and easy to follow, even for users unfamiliar with the technical aspects of calibration.

At this point, Spyder3 Elite goes ahead and fills in the rest of the details based on its baseline configuration.

Notice that, as expected, the Spyder3 Elite calibrates to a white point of 6500K and a gamma of 2.2 by default. For more advanced users needing to customize their calibration, however, adjustments to all of these values are just a click away under the "Expert Console."



As we'll see shortly, the Spyder3 system also sometimes suggests modifications to these default settings based on hardware limitations or ambient light conditions as measured during its analysis.

Ambient Light Analysis

With most user variables supplied, the process is now largely back in the Spyder3 Elite's automated hands. Though not all calibration tools are so equipped, our test setup is able to make adjustments based on ambient light measurements, and thus before analyzing the display itself, the Spyder prompts the user to setup the colorimeter to take an ambient light measurement.



As before, with a visual guide on the screen showing you exactly what to do, taking the measurement isn't difficult at all: set the colorimeter in its stand and near the computer, click "Next," and the device handles the rest.

In my specific case, the ambient light levels during testing were "Very Low" according to the Spyder (an ideal situation, given that too much ambient light can alter how a screen appears to the eye). For this kind of lighting, the Spyder software suggests that a 5000K white point and a lower white luminance level than the default setting might be appropriate.



Because I regularly use my notebook under extremely high ambient light, I'll opt to keep my settings (which are optimized for bright ambient conditions), but in general, if your software and hardware support ambient light analysis and you tend to use your computer under consistent lighting conditions, it's best to accept the suggested settings. Also, whether or not your calibration tools measure ambient light, it's recommended that you do what you can to reduce overly bright external light sources for the reasons stated above. In the case of the Spyder3 Elite, the system will warn you repeatedly if your ambient light levels are too high.

Building a Profile

For the final phase of the calibration and profiling process, the colorimeter must actually come into contact with your display's surface in order to measure the monitor's output and make appropriate adjustments. In our case, the Spyder3 software shows exactly where to position the device.



Attaching the colorimeter to the screen is usually done either via a suction cup (better on CRTs than LCDs) or by hanging the colorimeter with its cable draped over the back of the display (many colorimeters have a sliding counterweight on the cable lead to facilitate this).



Theoretically, you could just as easily hold the device in place, though the process does take several minutes and the colorimeter needs to stay reasonably still during this time.

With the colorimeter in place, click "Continue" and the software begins, placing a series of solid color fields in front of the colorimeter for the device to "read" and evaluate. Roughly four minutes later, our machine wrapped up and prompted me to give the new profile a name.



With a profile created, Spyder3 Elite shows users the before-and-after results of calibration and profiling right in the utility interface. Several test images of different types (saturated, black and white, low-key, high-key, etc.) can be called up on the screen; click "Switch" and the profile is alternately turned on and off, allowing users to see before-and-after images in real time and evaluate the difference for themselves.



A display profile has now been built, and the utility can be closed out. That's really all there is to it.

EVALUATION AND RESULTS

With a display profile built, you're ready to get to work, and in most cases your involvement with the calibration tool will be limited until you need to calibrate again (Datacolor allows you to set a pop-up recalibration reminder and recommends that you recalibrate your display once a month or thereabouts, as display output tends to shift over time). The software automatically stores the profile such that the computer loads it on startup without being prompted.

Glitches and Bugs

At least that's the ideal setup, and in most cases it seemed to work alright for us. This is where making sure that all other calibration/profiling utilities are removed or disabled becomes critical, though: we had one test machine in our group of five (a PC laptop with multiple displays connected) that didn't want to automatically load its profiles on startup, though I'm not entirely convinced that this issue didn't relate to a phantom version of Adobe Gamma that we kept uninstalling but never seemed to actually go away. Chalk it up to a unique system problem, since it was isolated to one machine of five.

It should also be noted that the software was a little screwy on PCs, in particular, with multiple displays, only detecting the display that the software window was launched onto on the first load. To find the second display, I had to calibrate the first monitor, close the software, and relaunch it on the other display. Strange, but apparently true, as the process proved to be the same on two different machines with this setup. In a similar vein, be aware that a notebook that uses multiple displays only part of the time (as in a docking arrangement, where you use the notebook plus an external display at your desk, but also use the notebook stand-alone at home or on the road) can occasionally give Spyder3 Elite fits, causing it to clear the profile for the notebook display.

The Visual Results

In testing the system on several machines, the results, while not always dramatic, were often revealing. For instance, as I had long suspected based on comparisons with my other machines, the laptop shown in the walk-through tends to push a broad swath of the highlight range, making areas of an image look blown out that, in truth, contain plenty of tonal information. Similarly, the laptop's default profile tends a bit cool, though I honestly hadn't even noticed until I side-by-sided the new version with its original profile.

If you work under bright ambient light (most overhead fluorescents in office environments fall into this category), you may find that calibrated color on your screen looks a bit dull at first, with whites that look closer to gray to unaccustomed eyes. The Spyder3's ambient light measurement function strongly disliked the light in our office, and wasn't able to sufficiently adjust the white luminance to compensate. Similarly, it's widely known that the apparent contrast and brightness of LCDs, and especially laptop displays, shifts dramatically based on viewing angle. Again, ambient light and working conditions can be as important to accurate color reproduction as the display setup itself, and doing what you can to create a consistent work environment for photo editing will make the output results more consistent.

The Spyder's Studio Match function does a decent job of bringing multiple displays to parity, though differences in hardware often make exact matches difficult to achieve – the more different the hardware (trying to match a new LCD and an aging CRT, for instance), the less you should expect the displays to match exactly. In some extreme cases, you'll have to decide what match points are most important to you and calibrate with this in mind; thankfully, the Spyder's Expert Console is generally up to the task of making these kinds of one-off adjustments, and all but the most exacting users will do just fine in trusting the system to make the match as it thinks best. Even without running Studio Match, we found the Spyder's profiles to yield extremely similar results across a range of hardware – producing a slightly warm profile compared to other systems I've used, but showing few variations in color/hue and no apparent discrepancies in tonal range across systems.

Long story short, the calibration and profile tool does exactly what it claims to do, providing consistent color, contrast, and brightness (and, in turn, consistent image appearance) from one computer to another.

CONCLUSIONS

Even in limiting the discussion (for now) to display calibration alone, this overview is really just the tip of the iceberg. There are simply too many hardware- and software-specific differences in implementing consistent color management to even begin to touch on in a single review and tutorial. We'll talk a bit more about device-specific ICC profiling in Part II of this series, but if there are specific questions about calibration and profiling as it relates to a certain setup or piece of software, or about controlling workspace in programs like Photoshop to make the most of a profiled display, we're glad to continue the discussion in the forums.

Larger than this, however, I hope that this walk-through gets at the idea that while the concepts may be complex, using color management tools to calibrate and profile your display really isn't hard and shouldn't be intimidating. With a growing number of options on the market and prices for these systems coming down into very reasonable territory, if you've been struggling to get your images under control, it's never been easier or cheaper to manage color in your workflow.

Stay tuned for Color Management, Part II, in which we'll bring things full-circle by profiling our printer output and do some analysis to see how much of a difference it ultimately makes.