Drop down list OnSelectedIndexChanged without .aspx page

Sharepoint is very keen on using CAML to add controls to your pages. Which means the traditional way of adding an event handler to your asp:DropDownList tag isn't available. (as far as I can tell, anyway.)

So, here's how to work around this in your code behind:

ddlSort.AutoPostBack = true;
ddlSort.SelectedIndexChanged += new EventHandler(ddlSort_SelectedIndexChanged);
this.Controls.Add(ddlSort);

DirectoryEntry properties

Here's a list based on a script I found at: http://geekswithblogs.net/mnf/archive/2006/04/20/75646.aspx

(Of course, bloggingaccident.com is not a SharePoint site and certainly doesn't have AD, but I changed the domain to it to protect my innocent VM.)

objectClass=top;person;organizationalPerson;user

cn=teststudent2

sn=Student2

givenName=Test

distinguishedName=CN=teststudent2,CN=Users,DC=bloggingaccident,DC=com

instanceType=4

whenCreated=7/23/2008 2:59:23 PM

whenChanged=7/24/2008 8:12:12 PM

displayName=teststudent2

uSNCreated=System.__ComObject

memberOf=CN=Group Name,CN=Users,DC=bloggingaccident,DC=com

uSNChanged=System.__ComObject

name=teststudent2

objectGUID=System.Byte[]

userAccountControl=66048

badPwdCount=0

codePage=0

countryCode=0

employeeID=927654321

badPasswordTime=System.__ComObject

lastLogoff=System.__ComObject

lastLogon=System.__ComObject

pwdLastSet=System.__ComObject

primaryGroupID=513

Active Directory Discovery: this will be totally useful

In reading up on the Active Directory Schema, I came across this little gem that proves Redmond does think of everything:

drink Attribute

The drink (Favorite Drink) attribute type specifies the favorite drink of an object (or person).

http://msdn.microsoft.com/en-us/library/ms675651(VS.85).aspx

I think I need a drink now.

SharePoint Hassles: The user does not exist or is not unique

In trying to add a user to a newly created site, I got this error. Turns out that I needed to add the user's domain to the SPRoleAssignment:

SPRoleAssignment oRoleAssignment = new SPRoleAssignment("DOMAIN\\User_Alias","User_Alias@Somewhere.com","Display_Name","Notes");

This now seems to find the user, but is giving me a security error when I try to update the role assignments: "The security validation for this page is invalid." but at least it is finding the user.

The solution to that error is to set spNewWeb.AllowUnsafeUpdates = true;

SharePoint Hassles: Script for Creating Subsites

As I'm learning SharePoint, I'm encountering all sorts of strange issues. Here's some workarounds.

Site Creation
I needed a script to allow a user to create a subsite. It worked fine as the System account, but not as a Contributor. Here's the code that finally worked:

public static void CreateSite(string sSiteUrl, string sTemplateName, string sSiteCollectionAdminName, string sSiteName, string sTitle, string sDescription, string sUserName, string sUserEmail, string sUserDisplayName)
{
//If you just open the site without passing the token then the current windows's user (if windows authentication is used),
//is used. To ensure site collection admin's token during the template upload and creation process, the adminUserToken is used
SPUserToken adminUserToken = GetUserToken(sSiteUrl, sSiteCollectionAdminName);
if (adminUserToken == null)
{

Titanic Housing

Comments on blogs today are really showing great insight. This is from a comment on an article comparing mortgage products and the Titanic (not a bad read itself).

"Just as during the Great Depression, when bad paper was knowingly being sold to investors, the government was aware but condoned the actions by the banks and took NO action to preserve the “prosperity” the nation was enjoying. More millionaires were being created then ever before. Sound familiar?"

Here's some retro real estate advice to remind you of the times that were.

Small Step to Reduce Oil Dependence

I'm not a greenie. I have some serious doubts about a lot of claims made by the eco industry. But, I do believe we need to reduce our dependence on oil and I can totally bring myself to take a spare bag or two to the grocery store with me if that helps a bit.

Another idea that appears to only be in the UK now is a site called Freecycle where you can give away unwanted items. And see what others have that they now consider rubbish.

A Stalin Conspiracy

...lurking in the comments of an article on The Ten Biggest Stock Market Crashes of All Time.

The list puts an interesting perspective on the current market. We've got the housing mess and high oil prices. Two out of three...

Makes More Sense Than Putting Them On Two Legs

The US Army was planning on using some nifty armed robots in it's various wars (or "policing actions" if you remember the 90s. Since another Dem is prolly going to be in the house next year, we may as well refresh ourselves on the terminology.)

Of course, as in all software, the real testing ends up happening in the wild. By my calculations, Terminator should be arriving right about when I'm ready to retire. At the earliest. Unless, you know, the Chi-Coms, Russkies or Swiss beat us there.

Syndicate content (C01 _th3me_)