Using Active Directory Searching/Lookup in a SharePoint/MOSS 2007 Workflow (with Visual Studio 2008)

Download this episode

Download Video


This is the eighth in a series (the series is listed at the bottom) of "How To " Videos that I have created to show .NET Developers how to build document workflow in a SharePoint environment. 

In the How to Videos that I produced on "Building Approval Workflow's" and "Escalating Workflow's (for overdue tasks), I kept things simple (focusing on the Workflow) and did not do dynamic lookups of people/users against Active Directory (AD), choosing to "hard code" the users in the workflow.

In this example, I take one of those workflow's (Basic Approval Workflow) and show you how you can do a "Dynamic Lookup or Search" of Active Directory for information (The Manager of a user) using .NET Code (System.DirectoryServices).

Code Download & Workshop Document Location: Click here 

Click here to access the larger framed Hi-Resolution Version from my blog!

You can also download the Freely Downloadable "Building Custom Document Workflow with MOSS with Visual Studio 2008" workshops (Developer Content) on my blog ( under the SharePoint Tag, or directly by clicking here.

Checkout my other Active Directory (non-SharePoint Specific) with .NET Videos: (The same code works in SharePoint)

  • How to Add users to Active Directory with .NET (Click here to see it) 
  • How to Search Active Directory (used as the bases for this video): (Click here to see it) 
  • How to Search for/Add users to "Groups" in Active Directory with .NET: (Click here to see it)

My other SharePoint videos:

  • Enabling (incoming/outgoing) email for SharePoint/MOSS 2007 servers (Click here to see it)
  • Extracting document details from within a workflow (Click here to see it)
  • Extracting email addresses and sending emails (Click here to see it)
  • Programmatically Creating a User Task within a workflow (Click here to see it)
  • Programmatically Escalating an Overdue Task with Visual Studio (Click here to see it)
  • Building an Approval Workflow with SharePoint/MOSS 2007 and VS 2008 (Click here to see it)
  • Building a Multilevel Approval Workflow with SharePoint/MOSS 2007 and VS2008 (Click here to see it)
  • Using Active Directory Search/Lookups within SharePoint Workflow's to find users (Click here to see it)

Note: If you have questions/comments, please leave them on my blog at this link, as I do not monitor this feedback URL.




Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Andrej Salnik
      Nice demo, but do not use Web.AllUsers collection to retrieve the SPUser Object from SharePoint.

      use Web.SiteUsers to retrieve a SPUser Object.

      if the user never loged in to the SharePoint Site on which the workflow is runing he/she will not be in the AllUsers collection and you will get an exception.


    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.