Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3440884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:29:08+00:00 2026-05-18T08:29:08+00:00

I am quite stumped with this. In enhancing an existing feature to a SharePoint

  • 0

I am quite stumped with this. In enhancing an existing feature to a SharePoint solution, I found that they were querying the Wss_Content directly. Knowing I should not be using that stored procedure, I used the SharePoint object model to retrieve the users group information from the userName. What’s burning me is that it is slower then the stored procedure. Is there a smarter/faster way to get this information? We are using SharePoint 2007. Below is roughly what the function does:

private string GetTitle(string userName)
    {
        string results = string.Empty;
        try
        {                
            SPSite spSite = new SPSite("http://devvm");
            SPWeb spWeb = spSite.AllWebs[""];
            SPUser user = spWeb.AllUsers["aspnetsqlmembershipprovider:" + userName];
            SPGroupCollection groups = user.Groups;
            results = groups[0].Name;
        }
        catch (Exception ex)
        {
            Console.WriteLine("Unable to find user" + userName);
            results = "No Group Found";
        }
        return results;
    }

and the Stored Procedure code is:

SELECT @role=Groups.Title
    FROM WSS_Content.DBO.UserInfo  Info
    LEFT JOIN WSS_Content.DBO.GroupMembership Membership 
    ON Info.tp_ID=Membership.MemberID
    LEFT JOIN Wss_Content.DBO.Groups Groups 
    ON Membership.GroupID=Groups.ID
    WHERE tp_Login='aspnetsqlmembershipprovider:' + @username

FYI the reason I have this in a try-catch is that this is a sub-query to another list that might not have a user associated to the item.
Any help in this would be greatly appreciated.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:29:09+00:00Added an answer on May 18, 2026 at 8:29 am

    How are you calling that code? If you are using this inside a console application then yes it will be slower, it needs to fire up the supporting objects that are normally live when using this inside a native sharepoint context.

    Also you are referencing an SPSite and SPWeb object without disposing of the object, this has inherent performance issues as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been stumped on this for quite a while now. I am trying
Ok, I'm quite stumped here. I'm getting an error, eclipse/android is saying that my
I have been stumped on this for quite awhile. Request#, SlotId, Segment, and Version
I'm quite stumped on this issue. I have a large library of H.264 mp4
I am truly stumped this afternoon and have done quite a bit of searching
The answer to this question is probably quite simple - but I'm stumped. I
I'm stumped as about how to do this correctly. I found this and am
I'm quite stumped by a problem where I would like an animation that I
I thought this would be quite simple but then realised that I couldnt find
I have been trying to find a solution to this everywhere but am stumped.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.