How to manage NT accounts through ASP application skills

Source: Internet
Author: User
'=============================================================
' Thank you for using the utility function program developed by the ASP001 studio
' HTTP://WWW.ASP001.NET
' ============================================================= ' ASP001 studio to provide you with custom program development, corporate Internet Outreach services
' qq:1974229
' E-mail:shenyangchuqi@tom.com
' More programs download please go to HTTP://WWW.ASP001.NET
'=============================================================
' Function Description: Manage NT account through ASP
' This function uses ADSI and requires Administrators group user rights
' Program development: ASP001 Studio Chuqi
'=============================================================
' Fill in the user
' Functional usage: AddUser (computer,username,password,fullname,info)
' Parameters: Computer name, account name, account password, account full name, account description
' Example: AddUser "127.0.0.1", "Test", "tests", "Testing Administrator Account", "This account number through ASP add"

' Modify the specified user profile
' Functional usage: edituser (computer,username,oldpassword,password,fullname,info)
' Parameters: Computer name, account name, account password, account full name, account description
Example: Edituser "127.0.0.1", "Test", "Test2", "Test Administrator account Modification", "This account has been modified through ASP"

' Delete the specified user
' Functional usage: deluser (computer,username)
' Parameters: Computer name, user name '
' Example: Deluser "127.0.0.1", "Test"
=============================================================

Function AddUser (Computer,username,password,fullname,info)
' Execute create account command
Set computerobj = GetObject ("winnt://" &computer)
Set NewUser = computerobj.create ("User", UserName)
Newuser.setinfo
' Make account Settings
Newuser.setpassword (PassWord) ' account password
Newuser.fullname = FullName ' account name
Newuser.description = Info ' account description
Newuser.userflags = &h10000 ' &h20000 (User must change password at next login) &h0040 (user must not change password) &h10000 (password permanently correct) &h0002 ( Account temporarily inactive)
Newuser.setinfo
Response.Write "Account" &UserName& "Create success!" "
Set computerobj=nothing
End Function

Function Edituser (Computer,username,oldpassword,password,fullname,info)
' Read user information
Set changeuserobj = GetObject ("winnt://" &Computer& "/" &UserName& ", User")
' Modify account password
If password<> "" Then
Changeuserobj.setpassword PassWord
Response.Write "Account Password modification success!" <br> "
End If
' Modify account name
If fullname<> "" Then
Userfullname = Changeuserobj.get ("FullName")
Changeuserobj.fullname = FullName
Changeuserobj.setinfo
Response.Write "Account name modified successfully!" <br> "
End If
' Modify account Description
If info<> "" Then
Userfullname = Changeuserobj.get ("Description")
Changeuserobj.description = Info
Changeuserobj.setinfo
Response.Write "Account description of the change success!" <br> "
End If
Set changeuserobj=nothing
End Function

Function Deluser (Computer,username)
Set deluserobj = GetObject ("winnt://" &Computer& "/" &username)
If ERR = &h800401e4 Then
Response.Write "User" &UserName& "does not exist"
Response.End
End If
Set delobj = GetObject (deluserobj.parent)
Delobj.delete "User", Deluserobj.name
Set deluserobj = Nothing
Set delobj = Nothing
Response.Write "Delete Succeeded"
End Function
Related Article

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.