myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


I got a Headache

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Management Products] >> Microsoft Systems Management Server >> SMS 2003 >> I got a Headache Page: [1]
Login
Message << Older Topic   Newer Topic >>
I got a Headache - 11/6/2008 4:48:22 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
I have this report that should Give me the name of users that are not TOP users RANK =1 on the machine.
but the problem, the resulting colunms are reversed, i.e. The users that are supposed to be Top users showing under Last Log On and vice versa...

Do you see where the logic is broken below? (of course I can rename the colunms but that would be faking it LOL LOL...)

select
v_R_System.Name0 as 'CPU Name',
v_R_System.User_Name0 as 'Last Logged on User',
v_gs_user_logon_info0.userrank0 as 'User Rank',
lastlogged.Email_Address0 as 'Last Logged on Email', v_GS_User_Logon_Info0.UserName0 as 'Top User',
topuser.Email_Address0 as 'Top User Email'
from v_R_System
inner join v_GS_User_Logon_info0 on v_R_System.resourceid = v_GS_User_Logon_info0.resourceid
left join v_R_user lastlogged on lastlogged.user_name0 = v_R_System.user_name0
left join v_R_user topuser on topuser.user_name0 = v_gs_user_logon_info0.username0 where v_GS_User_Logon_Info0.UserRank0 > 1 and v_gs_User_Logon_info0.Username0 != v_R_System.User_Name0
and v_gs_User_Logon_info0.Username0 != "domjoin"
and v_gs_User_Logon_info0.Username0 != "Administrator"
and v_gs_User_Logon_info0.Username0 NOT LIKE "IWAM_%"
Post #: 1
RE: I got a Headache - 11/6/2008 4:51:39 PM   
jnelson993


Posts: 959
Score: 132
Joined: 2/18/2005
From: Minneapolis, MN
Status: offline
First problem is you have double-quotes in the WHERE clause.  Double quotes indicate a column name, not a string.

_____________________________

Number2 (John Nelson)
MyITForum - Blog
MyITForum - Forum Posts

(in reply to MeenEnta)
Post #: 2
RE: I got a Headache - 11/6/2008 5:00:45 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
Thx John, the WHERE clause is fixed.

But the results still reversed between the colunms. TOP Ranked user and Last Logon user colunms.

(in reply to jnelson993)
Post #: 3
RE: I got a Headache - 11/6/2008 5:11:57 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
John, if I change it (see the red Font section) I get the proper names under the proper colunm, but the Ranking shows 1 on all of them.

select
v_R_System.Name0 as 'CPU Name',
v_R_System.User_Name0 as 'Last Logged on User',
v_gs_user_logon_info0.userrank0 as 'User Rank',
lastlogged.Email_Address0 as 'Last Logged on Email', v_GS_User_Logon_Info0.UserName0 as 'Top User',
topuser.Email_Address0 as 'Top User Email'
from v_R_System
inner join v_GS_User_Logon_info0 on v_R_System.resourceid = v_GS_User_Logon_info0.resourceid
left join v_R_user lastlogged on lastlogged.user_name0 = v_R_System.user_name0
left join v_R_user topuser on topuser.user_name0 = v_gs_user_logon_info0.username0
where
v_GS_User_Logon_Info0.UserRank0 = 1 and v_gs_User_Logon_info0.Username0 != v_R_System.User_Name0
and v_gs_User_Logon_info0.Username0 != 'domjoin'
and v_gs_User_Logon_info0.Username0 != 'Administrator'
and v_gs_User_Logon_info0.Username0 NOT LIKE 'IWAM_%'

(in reply to MeenEnta)
Post #: 4
RE: I got a Headache - 11/6/2008 5:42:51 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
The Logic is still wrong, because it has to be > 1

Basically the report should should a list of Last logon users that are not Top users = 1

Is that to much to ask...

I'm taking couple of Advils and going home..

(in reply to MeenEnta)
Post #: 5
RE: I got a Headache - 11/7/2008 11:05:06 AM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
Where did you get this view - v_GS_User_Logon_Info0 ?
Did you manually create it?

I tried to look at this, but I don't have this view in my DB.

_____________________________

Jeremy Gillean

(in reply to MeenEnta)
Post #: 6
RE: I got a Headache - 11/7/2008 11:17:48 AM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
I'm glad you asked, it is a great little utility, here's (attached) the DOC



Attachment (1)

(in reply to jgillean)
Post #: 7
RE: I got a Headache - 11/7/2008 11:59:00 AM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
Here's the problem...
I'm not sure how familiar you are with SQL, so I hope this makes sense.  In the following 2 lines of your query, you're assigning 2 different variables to the same view (v_R_User).  So, essentially any reference made to 'lastlogged' or 'topuser' is pulling data from the same view - v_R_User.  The syntax is correct, so you won't get an error.

left join v_R_user lastlogged on lastlogged.user_name0 = v_R_System.user_name0
left join v_R_user topuser on topuser.user_name0 = v_gs_user_logon_info0.username0

I can't test this since I don't have the same view in my DB, but I'm pretty sure you can remove those joins altogether.  Your SELECT statement doesn't reference v_R_User at all, so it's not needed.  If you can post the column names for this custom view, I'll try to help you with the query.


_____________________________

Jeremy Gillean

(in reply to MeenEnta)
Post #: 8
RE: I got a Headache - 11/7/2008 12:40:51 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
Sorry but i'm not following (my lack of knowledge); where can you pull from else than V_R_User ?

when I run my original report i get this reversed colunmed report (see PIC).



Thumbnail Image


Attachment (1)

(in reply to jgillean)
Post #: 9
RE: I got a Headache - 11/7/2008 12:47:03 PM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
Can you post the columns that are in the v_GS_User_Logon_Info0 view?

_____________________________

Jeremy Gillean

(in reply to MeenEnta)
Post #: 10
RE: I got a Headache - 11/7/2008 12:52:29 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
Here's the first part, the next will be in the next posting.. and Thank you for your assistance.


Thumbnail Image


Attachment (1)

(in reply to jgillean)
Post #: 11
RE: I got a Headache - 11/7/2008 12:53:18 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
Here's the 2nd part


Thumbnail Image


Attachment (1)

(in reply to MeenEnta)
Post #: 12
RE: I got a Headache - 11/7/2008 2:17:24 PM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
OK, I may be making some incorrect assumptions here, but it looks like you want the ranks associated with NON top users for a particular machine, in addition to being able to distinguish both the last logged on user and the top user for that machine.  With those assumptions...try creating a report with this query:

select distinct sys.name0 as 'Machine Name',
sys.user_name0 as 'Last Logged On User',
con.topconsoleuser0 as 'Top User',
comp.manufacturer0 as 'Manufacturer',
comp.model0 as 'Model',
os.caption0 as 'Operating System',
os.csdversion0 as 'OS Version',
ws.lasthwscan as 'Last HW Scan'
from v_r_system sys
inner join v_gs_system_console_usage con
on sys.resourceid=con.resourceid
inner join v_gs_computer_system comp
on sys.resourceid=comp.resourceid
inner join v_gs_operating_system os
on sys.resourceid=os.resourceid
inner join v_gs_workstation_status ws
on sys.resourceid=ws.resourceid
order by sys.name0

Save the report as something like "Last logged on user and top user per machine". (Remember whichever name you choose here)
Now create another report with the following:

select
sys.Name0 as 'Machine Name',
user_logon.UserName0 as 'User',
user_logon.UserRank0 as 'Rank (Top User = 1)'
from v_R_System sys
inner join v_GS_User_Logon_Info0 user_logon
on sys.resourceid = user_logon.resourceid
where sys.Name0 = @variable
and user_logon.Username0 != 'domjoin'
and user_logon.Username0 != 'Administrator'
and user_logon.Username0 NOT LIKE 'IWAM_%'
order by user_logon.UserRank0

On the General tab in the Report Properties dialog, choose "Edit SQL Statement..." and then click on the "Prompts..." button.
Create a new prompt called "variable" with the following SQL statement:

begin
if (@__filterwildcard = '')
SELECT DISTINCT SYS.Name0 from v_R_System SYS Order by SYS.Name0
else
SELECT DISTINCT SYS.Name0 from v_R_System SYS
WHERE SYS.Name0 like @__filterwildcard
Order by SYS.Name0
end

Make sure the "Allow an empty value" checkbox is unchecked.
Once the prompt is complete, click OK, and then OK again to close the SQL dialog window.
Enter a name for the report (e.g. "Ranked Users").
Choose the Links tab on the Report Properties dialog.
For the link type, choose "Link to another report" and select the first report that you just created (above).
Under prompts, make sure column 1 is chosen.
Finally, click OK.

When you're done, you should have a report, "Last logged on user and top user per machine", that lists all machines in your environment, and allows you to drill down into each machine to see the ranked users per machine.  Hopefully, this helps.

_____________________________

Jeremy Gillean

(in reply to MeenEnta)
Post #: 13
RE: I got a Headache - 11/7/2008 2:39:19 PM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
Sorry.  The Links tab applies to the first report, not the second one.  Hope I didn't add to the confusion.

_____________________________

Jeremy Gillean

(in reply to jgillean)
Post #: 14
RE: I got a Headache - 11/7/2008 4:38:42 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
Thx for the efforts jgillean, but that is not what I'm looking for, basicaly

The report should list the last logon users and related RANK # only if they are not top users i.e. RANK = 1

(in reply to jgillean)
Post #: 15
RE: I got a Headache - 11/7/2008 4:42:43 PM   
MeenEnta


Posts: 118
Score: 0
Joined: 9/9/2008
Status: offline
oh and in a separate colunm, it should show who is realy the actual Top Rank, like the PIC I posted earlier...

(in reply to MeenEnta)
Post #: 16
RE: I got a Headache - 11/7/2008 5:38:42 PM   
jgillean


Posts: 100
Score: 10
Joined: 1/17/2006
From: Memphis, TN
Status: offline
Well, there are 2 main problems with the approach that you've proposed.
1) The joins (mentioned above - post #8)
2) You're trying to combine Top User data (based on rank = 1) along with last logged on user data (only if rank !=1) in the same query.  This won't work due to the conflict with the ranking.  I would suggest pulling the Top User from another view (as below).

Also, I don't see the Email_Address0 column in the screen shots you attached.  I'll assume that you've added that.  This should give you what you want, minus the e-mail address for the Top User:

select
sys.Name0 as 'Machine Name',
sys.User_Name0 as 'Last Logged On User',
user_logon.userrank0 as 'User Rank',
user_logon.Email_Address0 as 'Last Logged On Email',
con.topconsoleuser0 as 'Top User'
from v_R_System sys
inner join v_GS_User_Logon_Info0 user_logon
on sys.resourceid = user_logon.resourceid
inner join v_gs_system_console_usage con
on sys.resourceid=con.resourceid
where user_logon.UserRank0 > 1
and user_logon.Username0 != "domjoin"
and user_logon.Username0 != "Administrator"
and user_logon.Username0 NOT LIKE "IWAM_%"

_____________________________

Jeremy Gillean

(in reply to MeenEnta)
Post #: 17
Page:   [1]
All Forums >> [Management Products] >> Microsoft Systems Management Server >> SMS 2003 >> I got a Headache Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.297