tags:

views:

229

answers:

2

How do I retrieve list of Active users (with account ids) in IIS 6.

A: 

II6 doesn't store user accounts and therefore doesn't expose any functionality to return user accounts.

marcc
+1  A: 

Providing that you mean active VISITORS on your site rather than active USERS, and the fact that I see that you're using asp.net... you could try the code below.

GLOBAL.ASAX

 Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
'Set the initial CurrentNumberOfUsers count to zero
Application("CurrentNumberOfUsers") = 0
 End Sub

 Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Add the newest user to the CurrentNumberOfUsers count
Application("CurrentNumberOfUsers") += 1
 End Sub

 Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Remove the last user from the CurrentNumberOfUsers count
Application("CurrentNumberOfUsers") -= 1
 End Sub

and then to retrieve that in your page, you would use something like

label1.text = Application("CurrentNumberOfUsers")

Now if you are trying to get the number of registerd users, you could try something like this.

Membership.GetNumberOfUsersOnline()

And if you need the total number of users on your site, you can use

Membership.GetAllUsers.Count()

As for the "With Account ID's" part... mmmm, not sure... prolly have to loop through each active account and pull it's ID.

rockinthesixstring
@rockinthesixstringWhat namespace has Membership ,does this imply that i must use Membership in my application ?Thanks - tony
TonyP
does your application authenticate users? If so, how? Are you usign Active Directory? If so, check this out http://msdn.microsoft.com/en-us/library/ms998360.aspx.
rockinthesixstring
Thanks, exactly what I was looking for..Yes, using ADS with little modification to my ADS library code I could get things done..
TonyP