Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Friday, March 30, 2012

How to get the Windows login name?

How to get the Windows login name inside SQL Server 2005 when the SQL Server
2005 is accessed thru terminal service? Cannot use .Net.Additional Information:
SQL Server 2005 is connected using SQL Authentication.
"Peter" wrote:

> How to get the Windows login name inside SQL Server 2005 when the SQL Serv
er
> 2005 is accessed thru terminal service? Cannot use .Net.|||You can't. SQL Server only knows the user as the SQL login.
-Sue
On Thu, 8 Mar 2007 16:52:03 -0800, Peter
<Peter@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Additional Information:
>SQL Server 2005 is connected using SQL Authentication.
>
>
>"Peter" wrote:
>|||Peter,
What client protocol are you using?
Chris
"Peter" <Peter@.discussions.microsoft.com> wrote in message
news:6442C4B1-5DC4-41F9-BCA6-410A3D95F50B@.microsoft.com...[vbcol=seagreen]
> Additional Information:
> SQL Server 2005 is connected using SQL Authentication.
>
>
> "Peter" wrote:
>

Wednesday, March 21, 2012

How to get the current User when using a general connection user

I have a VB.Net app and a SQL Server 2005 database. Users must login to use
the application, and I have an Employee table to store their details.
However, I use a common user ID to connect to the database (for reasons I
won't go into here).
My problem is, some of my triggers need to know who the current user is, and
of course I can't use the current connection information to get this as I
always get the common user ID.
Does anyone have a technique to solve this dilema? Maybe some way to set a
variable or something when I connect so that I can determine which user has
initiated the connection?You can use application roles to achieve that. Works something like this:
a) Every user has a Windows account using Windows Authentication
b) When they run the application you enable the application role
c) Inside the application's session you can look at what the username is,
including in triggers, using suser_sname()
Hope this helps,
Ben Nevarez, MCDBA, OCP
Database Administrator
"David" wrote:

> I have a VB.Net app and a SQL Server 2005 database. Users must login to us
e
> the application, and I have an Employee table to store their details.
> However, I use a common user ID to connect to the database (for reasons I
> won't go into here).
> My problem is, some of my triggers need to know who the current user is, a
nd
> of course I can't use the current connection information to get this as I
> always get the common user ID.
> Does anyone have a technique to solve this dilema? Maybe some way to set a
> variable or something when I connect so that I can determine which user ha
s
> initiated the connection?
>

Monday, March 12, 2012

How to get rid of the Database Login window ?

Hi, I'm a newbie in VB.Net, need some help here. I'm generating a report and view it in a win app, which is in VB.Net. I've specified the database logon info by the following code:

*************************************************
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
Dim crReportDocument As New cr1()
With crConnectionInfo
.ServerName = "mydb"
.UserID = "myuserid"
.Password = "mypassword"
End With

CrTables = crReportDocument.Database.Tables

For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

CrystalReportViewer1.ReportSource = crReportDocument

End Sub
*****************************************************

It's an Oracle DB and just one table, suppose to be very simple. But whenever the app starts, this "Database Login" window always opens first, asking for server info, db info, user name and password. Actually if I click "Cancel", the report still get generated. So how to get rid of this annoying "Database Login" window?

My second question is, how to automatically send this report to printer? I know in VB6 you just say action=1. Unfortunately this thing doesn't work in .Net any more.

Thanks!Just look through CrystalReport knowledgebase, seems that this is a known issue. Refer to this article:
http://support.businessobjects.com/library/kbase/articles/c2010461.asp

Is there already a fix for this ?|||Figured this out by carefully reading this article: http://support.businessobjects.com/library/kbase/articles/c2010461.asp

The Form_new method has to be overwritten, adding some customized initialization, where ser/uid/pass can be specified.

**** I just took it for granted to do it in Form_load...

Friday, February 24, 2012

how to get impersonate permission?

Say i have two login accounts in sql server 2005,I want to do context switch operation for two accounts.

I want to know to get impersonate permission....

any suggestions?

thanks

Try to use EXECUTE AS T-SQL command , see

|||

hi ggciubuc

I know I should use "execute as" command to implement impersonation.

But the command caller must have impersonate permissions... i want to know how to get the permission

thanks

|||

You can use the IMPERSONATE permission, it should be described in BOL (http://msdn2.microsoft.com/en-us/library/ms178569.aspx), but from a quick look to it, it seems like it may not be clear enough.

Here is a short description on how to use them.

For user impersonation, you need to connect to the appropriate DB and grant IMPERSONATE permission to the user using the following syntax:

GRANT IMPERSONATE ON USER::<<impersonated_context_user_name>>

TO <<grantee_user_name>>

for example:

GRANT IMPERSONATE ON USER::[user_to_be_impersonated] TO [user1]

go

For login impersonation, you need to connect to master DB and then grant the IMPERSONATE permission to the login:

GRANT IMPERSONATE ON LOGIN::<<impersonated_context_login_name>>

TO <<grantee_login_name>>

for example:

GRANT IMPERSONATE ON LOGIN::[login_to_be_impersonated] TO [login1]

go

I hope this information helps, and please let us know if you have any further question on this topic. We will be glad to help. We really appreciate your feedback on BOL; it will help us to improve our documentation and the general quality of SQL Server.

Thanks,

-Raul Garcia

SDE/T

SQL Server Engine