Passed 70-630 and 70-631

April 21st, 2009 by Rodney

Easy as pie :) Got  a 1000 on one and 973 on the other..

Now I have all 4 SharePoint certs, if only I could afford the MCM! :)

Passed 70-541 and 70-542!!

June 3rd, 2008 by Rodney

Hey all,

Today I took the 70-541 and 70-542 exams. WSS App Development and MOSS 2007 App Development. 55 questions each.  They weren't too bad. I took the WSS in VB (which was tougher, I'm a C# guy!) and MOSS in C#. Got a 918 on the WSS and 948 on the MOSS. Each took around 30 mins. Make sure you study up on the object model, XSLT, and the BDC before you take them.

 

Next up, the admin tests. Hopefully, I can get to those pretty quickly!

Adding subfolders programmatically when a new folder is created

May 16th, 2008 by Rodney

I was recently presented with the task of allowing subfolders to be created automatically whenever a new folder is added to a document library. I had my own ideas on how to go about this, and did some searching on the net to confirm, and found there were a couple of different snippets suggesting how to do it. Trouble is, in my instance, I needed an event handler that would create additional subfolders to the folder that was being created, at the time of creation. So I fooled around with it a bit, an voila! Here's what I came up with:

                   SPSite site = web.Site;
                   SPListItem listItem = properties.ListItem;
                   SPList list = listItem.ParentList;
                   SPDocumentLibrary docLib = (SPDocumentLibrary)list;
                   if (properties.ListItem.ContentType.Name == "Folder" && properties.ListItem.Folder.ParentFolder.ToString() == docLib.RootFolder.ToString())
                   {
                       String url = listItem.ParentList.RootFolder.ServerRelativeUrl.ToString();
                       SPFolder curFolder = docLib.RootFolder.SubFolders[listItem.Name];
                      
                       ////Create subfolders:
                       SPFolderCollection folders = web.GetFolder(url).SubFolders;
                       string folderURL = (site.Url+"/"+curFolder.ToString());
                       SPListItem newFolder = docLib.Items.Add(folderURL, SPFileSystemObjectType.Folder, "Second Level 1");
                       SPListItem newFolder2 = docLib.Items.Add(folderURL, SPFileSystemObjectType.Folder, "Second Level 2");
                       newFolder.Update();
                       newFolder2.Update();
                       listItem.Update();

                   }

Granted, this may not be the most efficient code for the purpose intended, but it DOES work. Feel free to comment with anything you might suggest that I should change, and why you feel that way.

Hope this helps!

Rodney

Update SPLIst Items with data from User Profiles

April 24th, 2008 by Rodney

Greetings!

I know it's been a while since I've posted, but I've been saving up! Party!!! I recently repsonded to a post by a user on the SharePoint University message boards in regards to updating a SharePoint list with information in a users profile via an ItemAdded event handler. I hope someone can get some use from this code. I found it very educating and entertaining to get it to work properly.

First, let's start with a list of available properties (by default) in a MOSS user profile:

UserProfile_GUID
SID
ADGuid
AccountName
FirstName
LastName
PreferredName
WorkPhone
Office
Department
Title
Manager
AboutMe
PersonalSpace
PictureURL
UserName
QuickLinks
WebSite
PublicSiteRedirect
SPS-Dotted-line
SPS-Peers
SPS-Responsibility
SPS-Skills
SPS-PastProjects
SPS-Interests
SPS-School
SPS-SipAddress
SPS-Birthday
SPS-MySiteUpgrade
SPS-DontSuggestList
SPS-ProxyAddresses
SPS-HireDate
SPS-LastColleagueAdded
SPS-OWAUrl
SPS-ResourceSID
SPS-ResourceAccountName
SPS-MasterAccountName
Assistant
WorkEmail
CellPhone
Fax
HomePhone

Of course, these can be added to with custom entries, but those are the defaults. Next, we look at how to get at these bad boys:

First, you have to reference Microsoft.Office.Server.UserProfiles and add the Microsoft.Office.Server dll to your project, as well as the standard stuff.

                using (SPWeb web = properties.OpenWeb())
                {
                    //Get the current site, list item being added, current user and context

                    SPSite site = web.Site;
                    SPListItem listItem = properties.ListItem;
                    SPUser user = web.CurrentUser;
                    ServerContext Context = ServerContext.GetContext(site);
                   

                     //Get the user's profile manager from the current context and ignore privacy

                    UserProfileManager upcm = new UserProfileManager(Context, true);
                    PropertyCollection props = upcm.Properties;
                  

                    //Get the user profile

                    UserProfile userprof = upcm.GetUserProfile(user.LoginName);

                    //Get the property you want the data from
                    UserProfileValueCollection name = userprof["PreferredName"];

                    //write property value to list item
                   
                    listItem["Title"] = name;
                    listItem.Update();

                }

Of course, you can change the property to one from the list by changing PreferredName to something else.

Hope this helps!

Failure trying to sync

October 10th, 2007 by Rodney

There's always a lesson to be learned.  Such is the nature of the beast! The more we work with this wonderful product called SharePoint, the more we realize how sensitive it can be, and how wierd things just seem to "happen". I've ran into quite a few on this particular project, and decided to post this in hopes of saving others some possible heartache.  If you've had errors in your event logs like these:

failure trying to synch site [SITE GUID} for ContentDB [contentdb GUID] WebApp [web app GUID]. Exception message was Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED

event id 5533 

or

 A runtime exception was detected. Details follow. Message: Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED))Techinal Details:System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED))at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex)at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op)at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op)at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(String strXml)at Microsoft.SharePoint.SPFieldCollection.AddInternal(String strDisplayName, SPFieldType type, Boolean bRequired, Boolean bCompactName, Guid lookupListId, Guid lookupWebId, StringCollection choices)at Microsoft.SharePoint.SPFieldCollection.Add(String strDisplayName, SPFieldType type, Boolean bRequired, Boolean bCompactName, StringCollection choices)at Microsoft.SharePoint.SPFieldCollection.Add(String strDisplayName, SPFieldType type, Boolean bRequired)at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.UserSynchronizer.TryAddFieldToUserInfoListWithInternalName(String strWSSInternalName, SPFieldType fieldType)at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.UserSynchronizer.AddFieldToUserInfoList(String strProfilePropName, SPFieldType fieldType)at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.UserSynchronizer.PushSchemaToList(Boolean& bAddedColumn)at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.UserSynchronizer.SynchFull()at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.Synch()at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)

evevt id 7888 

there's a good chance that you have a profile synchronization issue (or several).  Here are the steps I took to correct these errors:

1.      I downloaded a wonderful, free (yes, FREE!) utility called SharePoint Inspector, created by Gat Bouveret. His blog with a link to the codeplex download site can be found here.  I used this tool to identify the web applications and sites referred to by their GUID  in the event log errors.

2.      I opened a command prompt and typed stsadm- o preparetomove -Site http://whatevertheguiltysiteis -OldContentDb   <GUID of the contentdb listed in event log error>

3.      After this completed successfully, I ran stsadm -o sync -deleteolddatabases 0 (note: Depending on how long you've been seeing these errors, you may be able to use a switch greater than zero. If it's been 2 days since it synched last, you can use 2. You can tell this by typing stsadm -o sync -listolddatabases <number of days you think> and look for the offending content db guid.

In my case, there were 4 “my site” sites that were not syncing with the profile database. After  performing these steps, I rechecked the event log at the top of the hour to see if the errors had reoccurred. GONE! 

A little something extra: I have also had to do this on occasions where a web application was deleted, leaving the content db intact, and re-created attaching to the same content db without first running the prepare to move command. Same steps apply.

Hope this helps!

 

psconfig and database creation

September 19th, 2007 by Rodney

A few days ago, a colleague and I were rolling out a MOSS test enviornment for one of our clients, who wanted to name the Admin Content db something other than the default (which includes a nice, long GUID). Of course, we used the PSCONFIG utility to create our dbs before hand. Upon execution, my colleague was receiving authentication errors when executing the utility. Our first thought was that the account we were using had not been given sufficient priveleges on the SQL server. We spoke to the DBA who checked and verified that the correct permissions were there, so I had her check the SQL server logs to see what was happening when we were trying to hit it. Here is the error message that was logged:

Login failed for user 'DomainUsername". The user is not associated with a trusted SQL Server connection. [CLIENT: 192.168.1.5]

I then reviewed the script my colleague had wrote to execute the psconfig utility, and found that he was using the -dbuser and -dbpassword switches instead of -user and
-password.  Since it was a windows authentication account, this was causing the problem. DBUSER is only to be used with a SQL Authentication account.

 Hope this helps :)

 

Rod

This item is currently being updated by..

August 6th, 2007 by Rodney

Have you ever made changes to your MOSS enviornment and attempted to make a change in the Central Administration tool afterwards, and have an error page pop up telling you that it was unable to make the change because it was being currently being updated by Domainusername (probably your own!)? I ran into this a few times and found a solution. If you open the C:Documents and SettingsAll UsersApplication DataMicrosoftSharePointConfig there will be a folder with sort of a GUID name. I cut that folder out and pasted it on my desktop (to ensure nothing was needed) and ran the process again, and BAM! it worked! It appears to just contain XML files that keep track of the changes you make that (possibly) use the OWSTIMER. When one of those services gets choked up or doesn't complete, it kinda "locks you out" of making other changes.

 Hope this helps!

Rodney 

Workflows, SSPs, and IIS Nightmares

August 4th, 2007 by Rodney

What a week! 

I have had many challenges throughout my IT carrer, but this week has to rank near the top as one of the most stressful. I decided to take an offer with a new company, and turned in my 2 week notice. I hate leaving loose ends, and definitely don't want to leave my present company in bind, so I have a few projects that I wanted to complete before I left. Well, one of those projects included creating a workflow for a custom list for one of our departments. When I saved the workflow to the server and created a new record to test it, I found that it wasn't working. "Failed on Start" was all that was showing.

 

I looked at the code and everything checked out so I dug a little deeper and found that NONE of the workflows were working throughout the entire portal! ARGH! What happened? I started digging through the log files and they weren't much help at all. This is the only thing that was showing for workflows:

 

2/2007 14:11:51.52 w3wp.exe (0×10A8)                              0×05BC         CMS                                     Publishing                        7fz4    High             WARNING: Cannot change FormContext.FormMode to [Invalid] because it is already set to [Edit] 

 

08/02/2007 14:11:55.05     w3wp.exe (0×10A8)                              0×0EB4         Windows SharePoint Services       Workflow Infrastructure             72fs    Unexpected  RunWorkflow: System.ArgumentException: Value does not fall within the expected range.     at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties..ctor(SPWorkflow workflow, Int32 runAsUserId, String associationData, String initiationData)     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.MakeActivation(SPWorkflow workflow, SPWorkflowEvent e)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow originalWorkflow, SPWorkflow workflow, Collection`1 events, SPRunWorkflowOptions runOptions)      

   

08/02/2007 14:11:55.05     w3wp.exe (0×10A8)                              0×0EB4         Windows SharePoint Services       Workflow Infrastructure             98d7   Unexpected  System.ArgumentException: Value does not fall within the expected range.     at Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties..ctor(SPWorkflow workflow, Int32 runAsUserId, String associationData, String initiationData)     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.MakeActivation(SPWorkflow workflow, SPWorkflowEvent e)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow originalWorkflow, SPWorkflow workflow, Collection`1 events, SPRunWorkflowOptions runOptions)        

 

Well, to back track a little and set the scene, I had an issue a couple of weeks ago that caused me to have to do a restore from backup.  Upon the restore, I got my usernames for the shared services and application pools a litlte mixed up and wound up assigning the wrong username to the main portal app pool. To the best of my knowledge, they have the same permissions, but apparently one is missing something somewhere. (There's a lot of permissions to set on a farm implementation) I attempted to change it using the Central Admin interface, but to no avail. It didn't change in IIS. So, against the grain (totally taboo in the MOSS world), I tried to change the username and password for the main application pool in IIS. I clicked apply, ok, then did an IISRESET, and went back to check it at WHAM! Somehow, miraculously, it had changed itself back to the previous username and password! How is that possible? After a week of beating myself up over this, and hoping that it was somehow related to my worfklow issue, I called Microsoft Premier Support.  The fellow I spoke with was very knowledgeable and friendly, but had never seen this issue before either. We spent 3.5 hours working on it one day and another 3 hours the following day. We found that if we created a new app pool in IIS and assigned the main web application in SharePoint to that pool with the proper identity, workflows started working!! However, I digress..

 

That was not satisfactory as it was not supported by the MS team. So we deleted that app pool, and proceeded to delete the current web application using the Central Admin tool and recreate it, attaching the current content DB.  Once done, the workflows were broken again! We checked the IIS app pool and it was back to the wrong identity! We tried changing it manually with the same result as before, failure after IISRESET.  He put me on mute while he discussed options with colleagues because we were all bumfuzzled at that time. While I was waiting,  I started skimming through my MOSS Administrator's Companion and stumbled on a section instructing someone on how to change the username and password for an SSP. I thought to myself, "Surely, you've checked that, but let's do it again just in case…" Sure enough, there was the SSP credentials running under the same username as the app pool. I changed it to the correct one, did the same for the main app pool in IIS, did another IISRESET and BOOYAH! IT WORKED!!!!

 

So Ladies and Gentlemen, the morale of the story is this: If you do a restore from backup, make sure to use the same usernames and password for everything, but if you don't, change the username and pass for the main SSP, change it for IIS, and reset and you'll be back to normal. On one hand, I love SSPs for the additional load balancing functionallity, but they are truly a pain in the rear.

 

I hope this helps someone, if so please feel free to leave feedback/comments!

Rod

Welcome!

June 30th, 2007 by Rodney

Hello everyone and welcome to Sharepoint Squared, my online rant about my favorite topic, as well as other things that may come about from time to time.

It's great to have Sharepointblogs.com back up and running!  Thanks to Dustin and whoever else helped in the process of bring it back online! This site has been such a wonderful place of information for me, that I felt it only right to "share" some of that knowledge with the rest of you (pardon the pun Stick out tongue)

My name is Rodney Langley and currently I'm the SharePoint Webmaster for The Road Home Program, the largest recovery effort in history. We have over 2600 users and 235 Sharepoint sites running MOSS 2007, working hard every day to help the folks of the state of Louisiana rebuild thier homes which were damaged or destroyed by hurricanes Rita and Katrina. As you can imagine, it's a pretty busy job for one fellow (me) to administer and develop for. I'll do my best to blog often, but spare time is indeed a luxury so check back often!

As always, feel free to post questions or comments on anything and I'll respond as soon as I can!

 Rodney Langley