Tuesday, February 19, 2008

Find localized name of the Everyone group

Today a colleague asked me if there is any way to find out what the Everyone group is called in a localized version of Windows. In a Swedish Windows, this group is kalled "Alla" and in a German version it's called "Jeder" etc.

There is an easy way to do this with .NET with the (new) .NET 2.0 Security functions.

SecurityIdentifier si = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
NTAccount everyOneGroup = si.Translate(typeof(NTAccount)) as NTAccount;
if (everyOneGroup != null) {
Console.WriteLine(everyOneGroup.Value); // now contains the localized name
}

Tuesday, February 12, 2008

Relative URL in Sharepoint is incorrectly resolved

Today I had a problem with the TreeView WebControl. I wanted to set the NavigateUrl to a relative url in Sharepoint in one of my webparts (I allow user configuration of this property so this must be resolved correctly).

When I set the NavigateUrl to "test.aspx" it's resolved to: "_catalogs/masterpage/test.aspx" which probably has something to do with the fact that the webpart manager containing my webparts is declared in the masterpage.

The solution was simple: Use Page.ResolveUrl before setting the url. This correctly resolves the relative url before it's set to the TreeView:

string relativeUrl = "test.aspx";
treeNode.NavigateUrl = Page.ResolveUrl(relativeUrl);

Friday, February 1, 2008

CSS reference map!

There are a lot of css classes defined in Sharepoint and it's not always easy to know what they look like. There is however a great site that lists all sharepoint css classes with examples:

http://www.heathersolomon.com/content/sp07cssreference.htm