Friday 28 May 2010

Include or Exclude Users from SharePoint Profile Import

During a (default) import of user profiles (from Active Directory (AD)) inside SharePoint (MOSS) you will notice a bunch of user profiles you are not interested in (like system_mailbox, some dummy users as well as disabled accounts).
I was wondering if it would be possible to exclude these AD user profiles during the profile import in SharePoint. After a little search, I found the solution to obtain this.

You need to go to your SharedServiceProvider (from within the Central Administration). Navigate to 'User Profile and Properties' > 'Manage Connections'.
Here you will find the field called 'User filter'. The content will look like this (which is default):
(&(objectCategory=Person)(objectClass=User))

Between '(&' and the last ')' (let's say the filter placeholder) you can add fields you want to filter on. Add the following string just after the last fieldfilter to exclude those user accounts that are disabled in AD:
(!userAccountControl:1.2.840.113556.1.4.803:=2)
So the entire string will be like this:
(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))
If you also want to include only those user accounts where (e.g.) the company name is filled in, you need to include (company=*). In reverse, if you want to exclude those that have a company name, just place a exclamation mark right for company: (!company=*). The 'include' version will then look like this:
(&(objectCategory=Person)(objectClass=User)(company=*)(!userAccountControl:1.2.840.113556.1.4.803:=2))
An easy way to figure out to create your own filtersyntax (like company start with 'bla'), you can build easily a query inside AD which will show you the correct syntax.

3 comments:

kingston123 said...

your post is so good.thanks for this post...
kijiji calgary

attiqshah said...

i came to your blog instantly and amazed to see that its full of info what i was searching for
CarMax Burbank

attiqshah said...

i came to your blog instantly and amazed to see that its full of info what i was searching for
CarMax Burbank