Tuesday, 14 September 2010

Restrict site collection users to a specific OU using PowerShell

There may be a scenario where you might want to restrict a site collection to only permit users from a specific Organizational Unit (OU) hierarchy in Active Directory for assigning permissions. For example, I have two OUs in AD called IT Team and Accounts. IT Team contains a user called “Shaun Young” and all other users are present in the Accounts OU, as shown below:



In SharePoint, I have a site collection called “IT Team” which by default allows me to add any user from Active Directory:

Before command

For this example, I want to restrict the site collection so that only members of the IT Team OU are able to be given permissions to the site collection. I can do this in PowerShell by simply typing one line:

Set-SPSite -Identity "http://portal/sites/IT Team" -UserAccountDirectoryPath "ou=IT Team,dc=pacdomain2,dc=local"

Now when I search for an account, it shows me an error if I try any account from the Accounts OU:

after command

Note that specifying an OU using this command will still allow the principal picker to search for users below the OU that you have restricted – in other words, you are not restricting the ability to add users from just one OU, as you can still find users from the entire OU hierarchy below it.

To restore the site collection back to the default setting, type the command again with a double quote for the UserAccountDirectoryPath setting, as follows:

Set-SPSite -Identity "http://portal/sites/IT Team" -UserAccountDirectoryPath ""

The functionality provided by this cmdlet mirrors that provided by the setsiteuseraccountdirectorypath stsadm command introduced in Office SharePoint Server 2007 SP1, which has an article on TechNet here. There is some important information in this article that describes the behaviour of this command should you use it on new or existing site collections:

If a site collection is new and an administrator uses the setsiteuseraccountdirectorypath operation to specify a target OU, only users under the specified path can be added to the site collection and no one else can be added to the site collection.

If users have already been added to a site collection and the setsiteuseraccountdirectorypath operation is run, only users under the specified path will be able to be added going forward.

Unlike the Peoplepicker-serviceaccountdirectorypaths property where multiple OUs can be specified, only a single OU can be set at a time when the setsiteuseraccountdirectorypath operation is used. As a result, this operation should only be run once per site collection.


  1. When i try this i can then only select members that already exist on the site. I remember reading before that you had to "activate" thisa ability. Do you knwo what is going wrong?

    1. Great Article Cyber Security Projects projects for cse Networking Security Projects JavaScript Training in Chennai JavaScript Training in Chennai The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. With career averages of 5.7 points and 3.4 assists per game as a backup point guard, the Bucks paid a steep price of $38 million over four years to acquire Matthew Dellavedova from the Cavaliers during the Carmelo Anthony Jerseys offseason. Dellavedova has been a divisive figure in NBA fan circles throughout his career, due in part to the perception that he is a dirty player (which can be Karl Anthony Towns Jerseys easily argued) and actually not a very good player (which can be easily disproved). So why the big money for a guy who many believe only served the purpose Stephen Curry Shoes of giving Kyrie Irving time to catch his breath?The Bucks didn’t necessarily pay him for what he’s accomplished to this point or what he has the potential to become Paul Pierce Jerseys in the future. They invested in Dellavedova because he’s what their roster needs right now to maximize its potential.There are two simple reasons why that’s the case, the first Kyrie Irving Jerseys being Dellavedova’s ability to thrive as a complimentary shooter. In his final season with the Cavaliers, Dellavedova made 1.9 3-pointers per 36 minutes at a 41.0 percent clip. That Jimmy Butler Jerseys frequency put him on the same page as Gordon Hayward, Dirk Nowitzki and Irving, and he converted those opportunities at a greater rate. Furthermore, Dellavedova ranked in the 95.6 Moncler Jackets percentile in spot-up shooting with an average of 1.24 points per possession and finished behind only Stephen Curry, Seth Curry, Jeff Teague and Troy Daniels in catch-and-shoot efficiency.What’s impressive Stephen Curry Jerseys about Dellavedova’s numbers as a spot-up shooter is it made up a significant portion — close to a quarter — of his offense. By playing alongside ball dominant players Marc Gasol Jerseys like LeBron James and Irving, around 40 percent of his total shot attempts were either open or wide open 3-pointers. Despite being labeled as a "point guard," he’s comfortable Cleveland Cavaliers Jerseys parking himself on the perimeter and waiting for someone to kick him the ball if opponents send multiple defenders at the ball handler as if he were a shooting NBA Jerseys guard.Dellavedova does have experience creating for himself and others in the pick-and-roll — his go-to move off the dribble is a floater or alley-oop to the cutting big man Moncler Sale

  3. The article you have shared here very good. This is really interesting information for me. Thanks for sharing!
    hotmail login |hotmail sign in |free hotmail login

  4. Obat Aborsi,, Obat Penggugur Kandungan,,
    Nice bag you can earn money from that
    Thanks for your posting
    Visit me @, Jual Obat Aborsi,,

  5. عزل الاسطح وعزل الخزانات يحتاج الي عمالة وايد عاملة محترفة ودربة
    شركة الصفرات تغنيك عن الشركات الوهمية العديد علي المواقع والمديا
    شركة الصفرات لعزل الاسطح
    عزيزي العميل افضل شركة عزل اسطح وخزانات بالرياض
    شركة الصفرات تقوم بخدمات العزل بمواد عازلة ممتازة
    شركة الصفرات لعزل الخزانات بالرياض

  6. También puede visitar una tienda de ladrillo y mortero de Michael Kors o su sitio web y comprar directamente un bolso Michael Kors desde allí. Usar un bolso de Michael Kors les permite a los demás reconocer que el habitante urbano educado toma la moda realmente con seriedad. Los bolsos de hombro son particularmente refinados y elegantes.

    {Bolsas Michael Kors Precios | Bolsos Michael Kors Outlet | Michael Kors Rebajas}

    En vacker konstnärlig skapelse av vävt läder, som ger ett skalskaligt utseende - liknar en snakeskin eller fiskhud, linjer utsidan av påsen. Läderens bältros är små läderringar. Det finns också gyllene accenter på väskan. Slutresultatet är svagt liknar kedjepost.

    {Michael Kors Rea | Michael Kors Väska Rea | Michael Kors Plånbok}

  7. This comment has been removed by the author.

  8. 90minup ข่าวกีฬา ฟุตบอล ผลบอล วิเคราะห์บอล พรีเมียร์ลีก ฟุตบอลไทย

  9. A beautiful purse or handbag from Coach Outlet Online can last for many years, and represent a great overall value.
    There are Michael Kors Bags Outlet in a large number of shopping malls located throughout the country.
    Cheap Michael Kors Bags is a great way to determine which models best suit your needs.
    Official Coach Factory Outlet Online all strive to provide comfort and convenience for their owners and the seams are double-stitched for maximum durability.
    Michael Kors Factory Store, has one of the most popular handbag and accessory lines on the market today.
    Coach Handbags Wholesale says a lady is classy, elegant and sophisticated.
    Coach Store Near Me trends come and go, but a Coach stands the test of time.
    The official Michael Kors Handbags On Sale Outlet regularly posts various handbags being offered for sale.
    Compare your Coach Bags On Sale Outlet to the logo provided on the website to make sure it is similar.
    All Michael Kors Outlet Online Store have serial numbers.

  10. No matter what type of Michael Kors Bags Outlet each individual got, they all had one thing in common. We all know that getting something on sale is like winning a mini lottery, but to find a name brand handbag like Michael Kors Black Friday Sale for instance, discounted is like a slice of heaven on earth. I have personally attacked my husband with hugs and kisses when finding Official Coach Outlet Online at discounted prices.

    Michael Kors Factory Outlet stores can be found in malls all over. MK Outlet and other Coach merchandise can also be found in some boutiques. Inspired by the same material baseball gloves are made from, these Coach Bags On Sale Online are versatile and stylish. Since it's conception, the Michael Kors Handbags Outlet has been produced into a variety of designs, colors, shapes, and styles that have won top pick of millions of women the world over.

    New Michael Kors Bags are the most sought after handbag. Since Coach Outlet Online is one of the most recognized name brands in the world of fashion, you will find A-list celebrities down to small girls wearing them.

    tags:Coach Outlet|Coach Bags Factory Outlet|Coach Purses Outlet

  11. CASA98 บริการ แทงบอลออนไลน์ แทงบอลเดี่ยว บอลเต็ง บอลสเต็ป

  12. “If a site collection is new and an administrator uses the setsiteuseraccountdirectorypath operation to specify a target OU, only users under the specified path can be added to the site collection and no one else can be added to the site collection.” bed sheets sale online , comforter sets full , gul ahmed bed sheets sale 2018 , bed sheet bridal , fancy bedspreads , cotton gadda shop near me , velvet blanket , cotton razai price , best sofa covers , pakistani lawn suits price

  13. Slotxo บริการ สล็อตออนไลน์ สล็อตxo แจกเครดิตฟรี พร้อม ทางเข้า slotxo เกมส์ใหม่กว่า 100 เกมส์ สมัคร slotxo ได้เลยตอนนี้ บริการ 24 ชั่วโมง.
    สล็อตxo บนมือถือ
    สมัคร slotxo
    สมัคร slotxo รับโบนัสฟรี

  14. Note that specifying an OU using this command will still allow the principal picker to search for users below the OU that you have restricted – in other words, you are not restricting the ability to add users from just one OU, as you can still find users from the entire OU hierarchy below it. wholesale ladies suits online , wholesale ladies suits online

  15. The best way to find out about famous people's net worth is searching for their name on celebrity networth then click.