Re: WSS: Finding My Sites through SQL
- From: drkaj <kbonfils@xxxxxxxxx>
- Date: Thu, 09 Aug 2007 07:35:36 -0000
On 9 Aug., 09:31, drkaj <kbonf...@xxxxxxxxx> wrote:
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
Btw... Its WSS 2.0 i'm dealing with.. (I know it sucks but i cant
convince my customer to upgrade :-( )
.
- Follow-Ups:
- Re: WSS: Finding My Sites through SQL
- From: Mike Walsh
- Re: WSS: Finding My Sites through SQL
- References:
- WSS: Finding My Sites through SQL
- From: drkaj
- WSS: Finding My Sites through SQL
- Prev by Date: WSS: Finding My Sites through SQL
- Next by Date: Re: MS Fab 40 KnowledgeBase template error
- Previous by thread: WSS: Finding My Sites through SQL
- Next by thread: Re: WSS: Finding My Sites through SQL
- Index(es):
Relevant Pages
|