Sunday, February 12, 2012

Check validity of NT username

Is there a stored procedure that can be run where you pass in a NT username
and it tells you if it is valid or not? I would like to do this because we
have users setup with access to our SQL Servers and as somebody leaves the
company we want to remove their login. Something like
sp_ntusername 'domain\username''
ThanksIt kinda old, but you can use that:
read/74014dd5ea712297/a9ad008666f52801?q=check+ntusers+sqlserver&rnum=1&hl=de#a9ad
008666f52801" target="_blank">http://groups.google.de/group/micro...>
008666f52801
Just changing the "net user" to "net user /domain YourdomainName
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Andy" <Andy@.discussions.microsoft.com> schrieb im Newsbeitrag
news:9F2B48E4-2C7C-4CB4-BA36-CAD604D9401A@.microsoft.com...
> Is there a stored procedure that can be run where you pass in a NT
> username
> and it tells you if it is valid or not? I would like to do this because
> we
> have users setup with access to our SQL Servers and as somebody leaves the
> company we want to remove their login. Something like
> sp_ntusername 'domain\username''
> Thanks|||Just a remark: But you should prefer using groups instead of single accounts
because they can be easier managed than those accounts, accounts wont be
"automagically" deleted if a account is deleted in the domain. Group
memebership but always applies if a user leave the company or the domain
group.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Andy" <Andy@.discussions.microsoft.com> schrieb im Newsbeitrag
news:9F2B48E4-2C7C-4CB4-BA36-CAD604D9401A@.microsoft.com...
> Is there a stored procedure that can be run where you pass in a NT
> username
> and it tells you if it is valid or not? I would like to do this because
> we
> have users setup with access to our SQL Servers and as somebody leaves the
> company we want to remove their login. Something like
> sp_ntusername 'domain\username''
> Thanks|||sp_validatelogins
From BOL:
Reports information about orphaned Microsoft Windows NT users and groups
that no longer exist in the Windows NT environment but still have entries in
the Microsoft SQL ServerT system tables.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Andy" <Andy@.discussions.microsoft.com> wrote in message
news:9F2B48E4-2C7C-4CB4-BA36-CAD604D9401A@.microsoft.com...
> Is there a stored procedure that can be run where you pass in a NT
> username
> and it tells you if it is valid or not? I would like to do this because
> we
> have users setup with access to our SQL Servers and as somebody leaves the
> company we want to remove their login. Something like
> sp_ntusername 'domain\username''
> Thanks|||Thanks for the post. I should actually rephrase my question. We have a
table in our data warehouse that stores a user's email address and the NT ID
.
When a job completes we send out emails to the users in this table. If we
do not remove people from this table when they leave, the job fails when it
tries to send an email to an email address that does not exist. Is there
some stored procedure that can be run that takes the NT ID as a input
parameter and then can return whether it is valid or not?
Thanks a lot for your help!
"Mike Epprecht (SQL MVP)" wrote:

> sp_validatelogins
> From BOL:
> Reports information about orphaned Microsoft? Windows NT? users and grou
ps
> that no longer exist in the Windows NT environment but still have entries
in
> the Microsoft SQL ServerT system tables.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Andy" <Andy@.discussions.microsoft.com> wrote in message
> news:9F2B48E4-2C7C-4CB4-BA36-CAD604D9401A@.microsoft.com...
>
>|||IF SUSER_SID('NTdomain\NTuser') IS NOT NULL
PRINT 'Valid'
ELSE
PRINT 'Bad'
Tim S

No comments:

Post a Comment