Thursday, August 27, 2009

LDAP filters for MOSS User Profile Import

A typical query for bringing users from AD to MOSS will be -

(&(objectCategory=person)(objectClass=user)

but this will bring all services and disabled accounts, to filter these accounts you can use the following methods -
To remove disabled accounts -
(!userAccountControl:1.2.840.113556.1.4.803:=2) - removes disabled accounts

To remove service accounts (accounts with Password Expiration disabled)
(!userAccountControl=65536)
or
(!userAccountControl:1.2.840.113556.1.4.803:=65536) //in my case this one worked

Here is your LDAP query with these filter -

(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!userAccountControl:1.2.840.113556.1.4.803:=65536))

There might be cases where you want to filter out a particular group, let say you want to exclude users from a group named - FilterGroup, under MYOU, in this case the query will be as follows -

(&(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!memberOf=CN=FilterGroup,OU=MYOU,DC=mydomain,DC=local)))

Some more examples -

Include only the accounts with valid email addresses
(&(objectCategory=Person)(objectClass=User)(mail=*com)

Exclude accounts that don’t have a first name
(&(objectCategory=Person)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!(!givenName=*)))

 Thanks to -
Some more resources -
MSDN – Active Directory Search Filter Syntax

Wednesday, August 19, 2009

List does not exist - SharePoint 2007

While creating a new site based on a site template if you get the following error -

An error occured while rendering navigation for requested URL: /{SITEURL}/currentopps/2009/Test2006. Exception message: List does not exist
The page you selected contains a list that does not exist. It may have been deleted by another user. Stack trace: at Microsoft.SharePoint.Library.SPRequest.GetListsWithCallback(String bstrUrl, Guid foreignWebId, String bstrListInternalName, Int32 dwBaseType, Int32 dwBaseTypeAlt, Int32 dwServerTemplate, UInt32 dwGetListFlags, UInt32 dwListFilterFlags, Boolean bPrefetchMetaData, Boolean bSecurityTrimmed, Boolean bGetSecurityData, ISP2DSafeArrayWriter p2DWriter, Int32& plRecycleBinCount) at Microsoft.SharePoint.SPListCollection.EnsureListsData(Guid webId, String strListName) at Microsoft.SharePoint.SPListCollection.EnsureListsData(String strListName) at Microsoft.SharePoint.SPListCollection.ItemByInternalName(String strInternalName, Boolean bThrowException) at Microsoft.SharePoint.SPListCollection.GetListById(Guid uniqueID, Boolean bThrowException) at Microsoft.SharePoint.SPListCollection.get_Item(Guid uniqueID) at Microsoft.SharePoint.Publishing.PublishingWeb.get_PagesList() at Microsoft.SharePoint.Publishing.CachedArea.GetChildPageIds() at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildren(NodeTypes includedTypes) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedTypes, NodeTypes includedHiddenTypes, OrderingMethod ordering, AutomaticSortingMethod method, Boolean ascending, Int32 lcid) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedHiddenTypes) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.GetChildNodes(PortalSiteMapNode node, NodeTypes includedHiddenTypes)


This error happens if you are using publishing feature in your site template.