kamagra how much to take

Replace The Default SharePoint People Picker With A Custom People Picker

At a recent customer of mine the question came up as to how we could replace the default people picker with a custom one that was tailored to some very particular AD queries to supplement the SharePoint calls. I read a few posts about replacing it across the board, notably this one:

http://www.binarywave.com/blogs/rajesh/Lists/Posts/Post.aspx?ID=4

which for the most part is accurate. But this looked like a lot of work.

Reflecting on how a majority of the security assignment stuff happens, the AvlInc.aspx page out of the Layouts directory is the primary workhorse. While modifying such pages out of the 12 hive isn’t technically the best route in terms of surviving updates and service packs, proper noting of the customization to re-integrate back was fine for my requirement.

That being said, after you get a custom picker working ala using inheritance for requisite SimpleQueryControl, PickerDialog, EntityEditorWithPicker classes to override the abstract inherited members with your own behavior, even if you replace the default picker on the page it will not work since the page is querying for a picker with id userPicker. You won’t be able to simply change your custom control to this id and expect it to work because the base type casting will not be supported, thus will throw a nasty error.

The easiest way around it is to toggle the visibility of the primary, OOB picker on the page to not visible, and then create your own code behind page for the AclInv.aspx. This will allow you to interrogate the accounts in the custom picker, copy them to the OOB picker, and then submit the changes (as a note, I am only concerned with one account being in the picker at a time). Once this is done change the page to look at your custom page for it’s code behind. In order to copy the accounts, you have to override the default Validate logic since you are trying to catch the account changes on the button click. To get the control on the page, you are not going to be able to use the orthodox FindControl method, but rather have to recursively search for the control using the Page root as a starting container.

  1. public class test : Microsoft.SharePoint.ApplicationPages.AclInv
  2. {
  3. public override void Validate()
  4. {
  5. var control = (CustomEditorType) FindControlRecursive(Page, "userPicker1");
  6. foreach (string account in control.Accounts)
  7. {
  8. userPicker.CommaSeparatedAccounts = account;
  9. userPicker.Validate();
  10. }
  11. }
  12.  
  13. public static Control FindControlRecursive(Control container, string name)
  14. {
  15. if ((container.ID != null) && (container.ID.Equals(name)))
  16. {
  17. return container;
  18. }
  19. return (container.Controls.Cast<Control>().Select(
  20. ctrl => FindControlRecursive(ctrl, name))).FirstOrDefault(
  21. foundCtrl => foundCtrl != null);
  22. }
  23.  
  24.  

Not saying this is 100% great, but as a proof of concept is accuratish.

share save 171 16 Replace The Default SharePoint People Picker With A Custom People Picker

2 Comments

  1. Bjørn Kjetil says:

    Looks like something i need to do, but with the AudiencePicker.
    Anny pointers to get this to work?

  2. helen says:

    You can use stsadm command to search in particular OU in the AD.

    http://www.ekhichdi.com/a/People-picker-doesn't-give-results-from-AD-98.html

Trackbacks/Pingbacks

  1. Links (7/26/2010) « Everything SharePoint/Silverlight - [...] Replace The Default SharePoint People Picker With A Custom People Picker [...]
  2. Links a lot, Sharepoint, Chartcontroll,xpath, SP Client Object Model « Just tinkering Blog - [...] Replace The Default SharePoint People Picker With A Custom People Picker [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>