Several common creation methods are listed a few days ago. SQL Server Login , Login , User , System stored procedures used by roles and Groups , Of course, you also need to check Connectiongstring String SQL Server Login and database users . The following two functions implement this function. , In essence, it is still used SQL Server For Search and verification. . The stored procedure used is : Sp_helpuser. Detection SQL Server Login is check [Marst] In the database [Syslogins] Table
Private Shared Function checklogin () Function Checklogin ( Byval CN As String , Byval Loginname As String ) As Boolean
Dim SQL As String
Dim Strtemp As String
SQL = " Use [Master]"
SQL + = " Select [name] from [syslogins] Where [name] =' " & Loginname. Replace ( " ' " , " '' " ) & " '"
Try
Strtemp = Executescalar (providertype. SQL, CN, commandtype. Text, SQL)
If Not Isnothing (Strtemp) Then
Return True
Else
Return False
End If
Catch Ex As Exception
Return False
End Try
End Function
Private Shared Function checkuser () Function Checkuser ( Byval CN As String , Byval Username As String ) As Boolean
Dim SQL As String
Dim Strttemp As String
Dim T As Datatable
Dim Dr As Datarow
Dim Susername, sloginname As String
SQL = " Exec [sp_helpuser]"
Try
T = Executedataset (providertype. SQL, CN, commandtype. Text, SQL, " T " ). Tables ( " T " )
For Each Dr In T. Rows
Susername = Dr. Item ( " Username " )
If Isdbnull (Dr. Item ( " Loginname " )) Then
Sloginname = " "
Else
Sloginname = Dr. Item ( " Username " )
End If
If Sloginname. tolower = Username. tolower And Susername. tolower = Username. tolower Then
Return True
End If
Next
Catch Ex As Exception
Return False
End Try
Return False
End Function
Other related content