Call System.DirectoryService From an ASPX page

I needed to troublehoot some active directory calls in my code--recompiling was a pain. The solution is to add this into you web.config file and add a reference tot eh dll that is registered in the GAC. Check that the dll on your server has the same public key token (c:\windows\assembly) and version #.

Thanks to http://www.velocityreviews.com/forums/t104353-imports-systemdirectoryser...

Save SharePoint Subsite as a Template

Never forget the most basic rule of debugging .NET apps

Turn off the bloody custom errors in web.config and set callstack to true....

Thanks to my colleague Nirav for pointing that one out to me.

I got a proper error message when I was receiving a File Not Found on one of my web parts.

Don't forgot to turn things back off in the web.config when you are done.

sharepoint "template selection" options missing

So, it's the probably all night long deployment... And we went to create our first site and only had one template available, to publish with workflow.

Here's how to get the others:

go to Site Actions > Site Settings > Modify All Site Settings then go to Page layouts and site templates under look and feel. From this menu, select Site Can only use the following site templates -- select all the ones you want to use and all of them should show in the Create Site dialog.

Thanks to:

http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/7f76...

More on global dll use

So, I updated my dll, but the projects that had called it weren't recognizing the change.

Perplexed, I tried a bunch of stuff and finally decided to increase the Assembly version, which led to a web control working properly, but not my web parts.

Turns out the correct solution was to recompile the webparts--but first I removed the reference to the shared dll, re-added it as Local Only = False (I'd added them as true earlier.) and re-deployed.

http://msdn.microsoft.com/en-us/library/t1zz5y8c(VS.80).aspx is something I should have read days ago.

Random sites that helped me during a deadline with automated Sharepoint site creation and permissions setting

****NOTE: Before doing any AD development, be sure your client isn't going to change their AD structure and that you have an accurate reproduction of their structure in your dev environment.****

I'll give more detail later, but these posts helped me:

A couple of things on site group creation. Though, I did learn that I can add an AD group to a sitge using the same code as adding an AD user to a site.

http://sharepointxperience.blogspot.com/2007/09/add-new-spgroup-programm...

http://www.sharepointblogs.com/tonstegeman/archive/2006/10/18/sharepoint...

http://www.eggheadcafe.com/software/aspnet/29624950/anonymous-access-and...

Checking the current user's permission on a web site or a list by code
http://www.sharepoint-tips.com/2008/04/checking-current-users-permission...

SharePoint: An error occured when previewing the Web Part.

Probably one of the more unhelpful messages I've received today.

There wasn't anything in the error logs either.

However, if I left the gallery and added the web part to a page, I got a nice error telling me what method was freaking out.

So, the public display shows more information about what is causing the problem than the admin display.

I'm glad it's close to quitting time... on a Friday.

SharePoint: Well, that's how I would have done it

So, I've been trying to iterate over the items in a discussion list.

I was doing the following:

SPList discussionList = web.Lists["Discussions"];
string sID= discussionList.ItemCount.ToString();

foreach (SPListItem spLI in discussionList.Items)
{
sID= spLI.UniqueId.ToString();
}

Even though the ItemCount property was returning 2, I wasn't seeing any items. Then, I noticed that if I used discussionList.Items.Count, I was getting 0.

Turns out SharePoint only returns REPLIES as Items. The initial part of a discussion is treated as a FOLDER. (Makes total sense....)

This will give you all the list items which have a reply message to it:

SPLists Lists = Web.Lists();
foreach (spListItem item in Lists.Items)

However, if you want the list items that don't have a reply message:

SPLists Lists = Web.Lists();
foreach (spListItem folder in Lists.Folders)

Durn cannot open .csproj error

This post fixed the problem for me:

http://it.toolbox.com/blogs/parthas/vs-net-error-unable-to-open-project-...

At least on the project I'm working on now. I fully expect to randomly get this astoundingly annoying error again and not have this solution work.

Some SharePoint Sharing Shenanigans

UPDATE ON LOCAL COPY INFO: http://bloggingaccident.com/content/more_on_global_dll_use

So, I've got code I want to reuse in SharePoint. It references DirectoryServices, so it has to be signed and trusted, which means building a DLL and storing it in the GAC.

I was a little perplexed on how to reference this in a SP web part though.

I found an article here: http://www.sharepointblogs.com/michael/archive/2007/07/06/sharepoint-sol... that is a good start.

While working with it, I received the error:

"Page Viewer Web Part: The Web Part you attempted to add no longer exists in the Closed Web Parts Gallery. Refresh your browser to update the Web Part Page and the Gallery."

Syndicate content (C01 _th3me_)