PHP uniqid() not unique in IIS

The PHP function uniqid() can have problems with uniqueness running on IIS. I encountered the problem when troubleshooting the Crayon Syntax Highlighter plugin for WordPress.

The first hundred or more calls return the same value. I was able to reproduce the issue on two different Server 2008 R2 installations, both were using IIS 7.5.7600.16385 and PHP 5.4.15. One had WinCache and the other had no caching. Another server, a non-R2 with IIS 7.0.6000.16386 and PHP 5.3.8 did not suffer from this problem.

The following code can be used as a test:

The problematic output:

[Read more...]

Use PHP and LDAP to get a user’s group membership, including the primary group

The function below queries a user’s memberOf attribute to get a list of groups. It then uses user’s primaryGroupID to retrieve the distinguishedName of the corresponding primary group. The results are returned in a single, neat, array. This function can have many applications including use with a login system.

The Function

Example Output

Use PHP and LDAP to list members of an Active Directory group (Improved)

PHP function that gets the members of an Active Directory group, and returns the Users’ attributes as an array.

This is an improved version of the snippet posted on 2/10/2011

The Function

Example Output