re:does author exist in AD RRS feed

  • Question



    Within a Publishing Site:-

    I am looking at querying AD to see if a page author exists.  Any ideas as to the best way to achieve this?

    many thanks

    Tuesday, November 27, 2007 10:40 AM


All replies


    Hey Nuggett


    Well, you might not have to dig that deeply.  By default, SharePoint uses Windows auth.  Does your site do this?  If so, are these authors all users of SharePoint?


    If they are, you can hit up the user collections of a web object, like so:


    public void Users()


    SPWeb site = SPContext.Current.Web;

    if (site.AllUsers["domain\\username"] != null)


    //user has logged into the site or is explicitly added to this site



    if (site.SiteUsers["domain\\username"] != null)


    //user is a member of the site collection



    if (site.Users["domain\\username"] != null)


    //user is explicitly added to this site




    However, if these authors are somewhere else, you'll need to hit AD.  In that case, I suggest making a web service that has methods to query your forest and return the information you need.  Your SharePoint code then calls this.  Let me know if you need more.

    Tuesday, November 27, 2007 6:57 PM

    Hi there..


    many thanks for you response.  Yes My site does use windows authentication, and all of these authors do exist in a sharepoint authors site group.  They have been added using their AD account.  For my purposes I am going to have to query AD; as this is where the account will be deleted when a user leaves my company.  I just need a way of looking at AD and if the user no longer exists....then flag it up.

    So going on what you recommend, i think a web service is going to have to be the way that goes.  Do you have sample code that I can use to get to my AD?...


    once again thx for your help.

    Wednesday, November 28, 2007 1:57 PM
  • No worries!


    I'm actally going to write up an article on this.  I'll reply with the link when it's up.

    Wednesday, November 28, 2007 3:00 PM
  • Nice one!...can't wait ;o)


    Thursday, November 29, 2007 9:46 AM
  • Saturday, December 1, 2007 11:11 PM