WSS: Finding My Sites through SQL
- From: drkaj <kbonfils@xxxxxxxxx>
- Date: Thu, 09 Aug 2007 07:31:13 -0000
Hi everybody,
I need to find all sites that a use has access to, and present these
sites on a diferent server than the WSS server. I have tried to do
this using the web-services, but the performance is rather poor. My
strategy was to find all sites on the server, and then try to get the
list collection for each site. If the user can get the list
connection, he must have access.. Any better way?
static void Main(string[] args)
{
WebsService.Webs ws = new ConsoleApplication1.WebsService.Webs();
ws.Credentials = new NetworkCredential("foo", "bar", "goo");
XmlNodeList AllSites =
ws.GetAllSubWebCollection().SelectNodes("*");
ListsServices.Lists listService = new
ConsoleApplication1.ListsServices.Lists();
listService.Credentials = CredentialCache.DefaultCredentials;
foreach (XmlNode node in AllSites)
{
if (UserHasAccess(node.Attributes["Url"].Value, listService))
{
Console.WriteLine(node.Attributes["Url"].Value + "\t" +
node.Attributes["Title"].Value);
}
}
listService.Dispose();
ws.Dispose();
Console.ReadLine();
}
private static bool UserHasAccess(string url, ListsServices.Lists
list)
{
bool result = false;
string wsUrl = url + "/_vti_bin/lists.asmx";
try
{
list.Url = wsUrl;
XmlNode node = list.GetListCollection();
result = true;
}
catch (Exception ex) { }
return result;
}
I know that MS doesn't recommend using direct DB access, but in this
case the performance is too slow. I tried to figure out how the db
works, and I came up with this SQL:
declare @userId as int
Select @userId = tp_ID from UserInfo where tp_login like 'DOMAIN
\username'
select 'http://wssserver/' + fullUrl from webs
where id in (
select wgms.WebId from webGroupMembership wgms
join WebGroups wg on
wg.Id = wgms.GroupId
and wg.WebId = wgms.WebId
where MemberId = @UserId
and wg.Type >2
union
select WebId from webMembers
where userId = @userId
)
order by fullUrl
Can anybody verify this sql?
I know that both the C# code and the SQL looks like !"#%!#¤"... But
its just quick prototyping to test the functionality...
Any other sugestions for solving the problem?
Regards, Kaj
.
- Follow-Ups:
- Re: WSS: Finding My Sites through SQL
- From: drkaj
- Re: WSS: Finding My Sites through SQL
- Prev by Date: RE: SharePoint Designer - List People and Groups
- Next by Date: Re: WSS: Finding My Sites through SQL
- Previous by thread: Re: Deleted config database
- Next by thread: Re: WSS: Finding My Sites through SQL
- Index(es):
Relevant Pages
|