August 10, 2004 at 11:00 am
SQL Server 7 using NT Authentication.
We have an application calling an sp that updates a table with among other things, the NT user by way of the GetUserName method.
We want to be able to query only a subset of NT users from the table that belong to a specific SQL Login (example - CaliforniaLocations).
I see nt_username in sysprocesses, but can I find all of the nt_usernames belonging to the CaliforniaLocations login?
Thanks
August 10, 2004 at 1:19 pm
I don't know about your SP, but you should be able to query NT-Username by group if they belong to a common group for CaliforniaLocations VBScript would be like below:
On Error Resume Next
Const ForAppending = 8
Sub PullUserLastLogin(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
UserLogin = User.LastLogin
End Sub
'4.18 Display User Last Logoff (NT 4.0 only)
Sub PullUserLastLogoff(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
UserLogoff strUser & VBCRLF & User.LastLogoff
End Sub
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set objNewFile = fso.OpenTextFile("C:\DomainUserInfo.csv", ForAppending, True)
Dim Dom
Dim Group
Dim Member
Dim strOutput
strDomainName="Domain"
strGroupName="California"
Set Domain = GetObject("WinNT://" & strDomainName)
Set Group = GetObject("WinNT://" & strDomainName & "/" & strGroupName)
For Each Member in Group.Members
strOutput=Null
If (Left(Member.Parent,8) = "WinNT://") then
strOutput2 = Member.FullName
strOutput = strOutput & Member.Name
Elseif Left(Member.Parent,7) = "LDAP://" then
strOutput = strOutput & Domain.Name & "," & GroupName & "," &_
Mid(Member.Parent,8,Len(Member.Parent)-7) &_
"\" & Member.Name &"," & Member.Class
Elseif (Left(Member.Parent,8) = Null) then
strOutput2 = Member.FullName
strOutput = strOutput & Member.Name
End If
'wscript.echo strOutput
PullUserLastLogin strDomainName,strOutput
'wscript.echo UserLogin & vbcrlf & strOutput2
'PullUserLastLogoff strDomainName,strOutput
'wscript.echo UserLogoff
objNewFile.WriteLine strOutput & "," & strOutput2 & "," & UserLogin
Next
objNewFile.Close
Set fso = Nothing
wscript.echo "Last Logon Information has Been written!"
August 10, 2004 at 1:37 pm
I guess I can execute in a DTS package?
Thanks for the help.
August 11, 2004 at 1:16 am
how about :
EXEC master..xp_logininfo @acctname = 'yourdomain\yourgroup',@option = 'members'
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
August 11, 2004 at 5:26 am
That did it. Thanks much.
September 28, 2004 at 9:53 am
Very usefull SP, do you have more documentation about this Extended SP?.
Thanks !
Pancho
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply