Show all Sitecore Active Directory users

I manage a Sitecore installation that’s integrated with an enterprise Active Directory.

We have over 11,000 accounts in our Active Directory. I needed a list of the Sitecore users, who are only a small percentage of the 11,000.

We have nothing in Active Directory that sets them apart, like group membership.

We architected our solution so that users are never assigned directly to items; users are members of Sitecore roles, and we assign Sitecore roles to items. All I have to do is rifle through all my Sitecore roles.

So how do I find my users? It took a little C#. Here’s the core code:

var roles = Sitecore.Security.Domains.Domain.GetDomain("sitecore").GetRoles();
foreach (var role in roles)
{
    foreach(var roleMember in Sitecore.Security.Accounts.RolesInRolesManager.GetRoleMembers(role, false))
    {
        if (roleMember.AccountType == AccountType.User)
        {
            var userObject = Sitecore.Security.Accounts.User.FromName(roleMember.Name, false);
 
            // only adding SMU domain users
            if (userObject.Domain.Name == "myActiveDirectoryDomain")
                AddUserToList(userObject);
        }
    }
}

This gets all Sitecore domain groups and extracts all users who are a member of my corporate domain. Of course, you’ll replace myActiveDirectoryDomain with your own domain name.

I created a separate AddUserToList method to handle adding these items to a Dictionary:

private void AddUserToList(User user)
{
    if (!_users.ContainsKey(user.Name))
    {
        _users.Add(user.Name,user);
    }
}

After the core code runs, you’ll need to code your own stuff to spit out what’s in the dictionary.

Here’s what I used:

foreach(var user in _users)
{
    var row = new TableRow();
    OutputTable.Rows.Add(row);
 
    row.Cells.Add(new TableCell { Text = user.Value.Profile.UserName });
    row.Cells.Add(new TableCell { Text = user.Value.Profile.FullName });
    row.Cells.Add(new TableCell { Text = user.Value.Profile.Email });
 
    if (user.Value.Profile.FullName.Length == 0)
    {
        row.CssClass = "alert";
    }
 
    var rolesCell = new TableCell();
 
    foreach (var role in RolesInRolesManager.GetRolesForUser(user.Value, false))
    {
        if (role.Domain.Name == "sitecore")
        {
            rolesCell.Text += "
 " + role.Name;
        }
    }
 
    rolesCell.Text = rolesCell.Text.Substring(7);
    row.Cells.Add(rolesCell);
}

Note that I already had a Table named OutputTable on my ASPX page.

Tadaa! The result is a list of all my domain members who are Sitecore users.

Absolve Chick-fil-A guilt with Gay Credits!

Carbon credits are sold as a way to buy indulgences offset carbon emissions.

I propose Gay Credits to absolve Chick-fil-A guilt. They’re cheap, only one penny per $10 of Chick-fil-A spending!

Here’s why:

Chick-fil-A donated $5 million to anti-gay groups over 8 years (2003-2010). Over this time, Chick-fil-a’s total sales were $18.8 billion.

What percentage of that $18.8 billion went to anti-gay groups? $5 million ÷ $18.8 billion = 0.027%. That is, 27 thousandths of a percent. In other words, for every $10 you spent at Chick-fil-A, about a quarter of a penny ($0.0027) went to an anti-gay group.

If this guilts you, you can have four times the impact of Chick-fil-A on the culture war if you donate only 1 penny to a pro-gay group for every $10 you spend at Chick-fil-A. Yes, just one penny!

Each penny is a Gay Credit, and each Gay Credit absolves $40 of Chick-fil-A purchases!

Now how do I make a market for this…

A message from the author

The point here is that one’s contribution to an anti-gay group through buying at Chick-fil-A is smaller than a rounding error, and you can 4X Chick-fil-A’s impact for almost nothing.

All this aside, public sentiment is clearly going against the anti-gay groups. Chick-fil-A’s donations aren’t affecting the long-term trend, which is clearly favoring equal rights for gays.

Appendix

Chick-fil-A’s annual sales numbers:

Upgrading hardened Sitecore content delivery environments

How do you upgrade hardened content delivery (CD) environments? Ours are so hardened that you can’t even get to /sitecore/admin/UpdateInstallationWizard.aspx.

Here’s how. It can be tedious, but these make it easier:

  1. CDs are mostly stripped-down instances of full Sitecore environments.
  2. Any needed database changes are handled when upgrading the content mastering (authoring) environment.

You only need to do 3 things on CDs.

But first, two notes:

  1. If you upgrade the CDs before you’ve upgraded the content mastering (CM) environment, you may have unstable CDs until the CM upgrade is done.
  2. Sitecore’s .update files are really Zip files. Just open it with your favorite Zip program, like 7-Zip, and it works like any other Zip file.

For each update file, do the following three steps. You must perform them in the release order of the update files, starting with the oldest release.

1. Add new or changed files

Extract everything in the addedfiles and changedfiles directories of the update file. You’ll extract them over the web root. Tell your Zip program to overwrite existing files.

2. Delete files no longer needed

This is the hardest part. Inspect the update package’s deletedfiles and deletedfolders directories of the update file. Every file (not folder) under each corresponds to a file or folder under your web root that needs to be trashed.

Note the wording: “every file“. For example, in Sitecore 6.5.0 rev.110602_fromv640rev101012_2.update, there is a file named AuthoringFeedback under deletedfolders\sitecore\shell\Applications\Analytics. That means you would delete the directory at sitecore/shell/Applications/Analytics/AuthoringFeedback under the web root.

You may have to dig deeply and thoroughly to find all files and directories.

3. Edit .config files.

Do all .config file changes that correspond to the update package you just handled. A list of .config file changes are at http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/webConfig.aspx.

Wrapping up

If you’re going through multiple upgrades, it’s tempting to do all them at once–do all the file additions at once, then all the file deletions, and then do all the .config changes. This might work as long as you work through the update files in their release order, starting with the oldest release, and if Sitecore didn’t delete something and add it back or vice versa.

For example, suppose you were doing four updates at once. In update #2, a file named x.png was deleted, but then it was added back in update #4. If you do all your file additions first, then do all deletions 2nd, your final state will have no x.png.

As long as you’ve been careful and did the CM environment upgrade first, the CDs should “just work” when done.

The challenge of Boy Scouts’s homosexuality policy

My family has a rich Scouting background. I tell people, “We have so many Eagle Scouts, even my gay brother is an Eagle Scout.” It’s true.

I don’t like Boy Scouts of America’s (BSA’s) homosexuality policy, which bars homosexual adult leaders. I’d like a change: our understanding of homosexuality has improved, and BSA’s policy needs to improve, too. But at the same time, I don’t think the public debate appreciates the risk of change.

Every Scout unit is owned by a chartered organization. A charter is a license to use Boy Scouts’s program.

Most chartered organizations have negative views of homosexuality:

  1. 56% of Scouts are in units chartered by religious institutions with officially negative views of homosexuality, like the United Methodist Church, Latter Day Saints (Mormon) Church, and the Catholic Church.
  2. 3% of Scouts are in units chartered by religious institutions that accept homosexuality, like the United Church of Christ.
  3. The remaining 41% are in units chartered by civic or educational organizations, and their stances can vary. For example, a University Park, Texas unit, chartered by a parents’ club, barred a homosexual parent from leadership based on objections of other parents. (My son’s pack is chartered by a PTA.)

Even when accounting for variances within institutions–for example, some United Methodist congregations are accepting of homosexuality, some United Church of Christ congregations don’t accept it–it’s still likely that most chartered organizations have negative views of homosexuality.

The BSA is in a difficult spot: its ultimate power, its livelihood, rests in chartering organizations–they run the Scouting units, they provide all the youth, and they have the final voting authority in BSA.

Can BSA survive if it angers most its chartering organizations?

I wish BSA could be neutral, letting chartered organizations do their own homosexuality policies, like what was recently proposed. But in seeking change, I don’t want to recklessly harm or destroy the centerpiece of the American Scouting movement.

I’m sure some of you will say this is still perpetuating discrimination. That’s just not true. It has taken decades, sometimes centuries, for society to correct civil rights problems. It’s not reasonable to expect the BSA to make instant-presto changes, especially given that it must be sensitive to the policies of its chartered organizations.

The ACLU’s scorched earth war on Boy Scouts isn’t the right solution. We can do this better, and we can do it right, with a pragmatic, dialogue-rich approach. In the end, destroying the organization is not the right way to fix its policies.

NTTA should set 75 mph speed limits

75 MPH speed limit signThe North Texas Tollway Authority (NTTA) can set 75 mph speed limits on much of its road system.

HB 1353, which was effective Sept. 1, 2011, basically says any road can have a 75 MPH speed limit (full text) if justified by TxDOT’s speed zoning procedure. Before then, 75 mph was only allowed in a few, politically-chosen  counties.

This speed zoning procedure generally requires the speed limit to be set at the 85th percentile speed of traffic.

What’s the 85th percentile speed? It’s the upper end of the “flow of traffic”.

Speed limits set at the 85th percentile speeds fully legalize this “flow of traffic”–the speeds of reasonable drivers–and only criminalizes demonstrably unsafe speeds. (more info)

What’s the 85th percentile speeds on NTTA roads?

Texas 121 TollOn the Sam Rayburn Tollway (TX 121), the average 85th percentile speed across the entire roadway is 74.1 mph. That rounds to 75 mph. Virtually all of the tolled part of TX 121 could be set to 75 mph with no hassle.

How about thePresident George Bush Turnpike logo President George Bush Turnpike? Not so fast. (Ha ha, get the pun?) 7 year old data has the entire road averaging a 71 mph 85th percentile speed. But wait, there’s more! 7 years ago, its speed limit was 60 mph! The speed limit is now 70, so the 85th percentile speeds have probably crept up. Plus there’s the new eastern extension, which may have changed traffic patterns. This entire road needs to be rechecked!
Dallas North Tollway logoThe last road is the Dallas North Tollway. It’s surprising:

  • Between I-35E and I-635 has a 73 mph 85th percentile speed! That rounds to 75 mph! It’s debatable if the sag curves under many of the bridges really need a 50 mph advisory speed. If that could be dispensed with, or raised to, say, 60 mph, then you could easily see a 70 or 75 mph limit on the old part of the DNT!
  • Between I-635 and the Collin County Line: 69 mph. This part could go to 70 mph.
  • Between the Collin County line and Sam Rayburn (TX-121): 73 mph, another 75 mph candidate!
  • Between 121 and the northern end: Surprisingly, only 69 mph! So the 70 mph limit there wouldn’t be changed. However, this measurement was taken when the speed limit was only 65. It’s 70 now, so the speed could have crept up a hair. This section needs to be rechecked.

If NTTA strictly followed the 85th percentile rule (which is only fair, since we motorists are expected to strictly obey traffic laws), and didn’t use arbitrary “engineering judgment” to force lower limits, we could see 75 mph limits on most of its road network.*

*A caveat: Because of a pointless, broken program called environmental speed limits, there may be red tape to raising the speed limit on DNT between Frankford Rd. and SRT (TX-121) and PGBT between I-35E and TX 78. None of the rest of the NTTA road system is subject to this program.

Here’s the raw data from NTTA: ORR-2-21-2012. This has the Excel files and strip maps. The Excel files have the speed checks. You’ll use the percentile function to get each location’s 85th percentile speed. The strip maps show where each speed check was run.