svn commit: samba r16033 - in branches/SOC/bnh: .
brad at samba.org
brad at samba.org
Sat Jun 3 19:30:39 GMT 2006
Author: brad
Date: 2006-06-03 19:30:38 +0000 (Sat, 03 Jun 2006)
New Revision: 16033
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16033
Log:
Removed ads_deluser.vbs and replaced with ads_adduser.wsf.
ads_deluser.wsf uses common error handling and reporting, and uses the <script src=lib.vbs > tag to include common.vbs.
Added:
branches/SOC/bnh/ads_deluser.wsf
Removed:
branches/SOC/bnh/ads_deluser.vbs
Changeset:
Deleted: branches/SOC/bnh/ads_deluser.vbs
===================================================================
--- branches/SOC/bnh/ads_deluser.vbs 2006-06-03 19:22:54 UTC (rev 16032)
+++ branches/SOC/bnh/ads_deluser.vbs 2006-06-03 19:30:38 UTC (rev 16033)
@@ -1,42 +0,0 @@
-const READ_ONLY = 1
-const USAGE_STATEMENT = "Usage: cscript ads_deluser.vbs /username:<username>"
-
-' This function returns the contents of a file.
-' When passed the name of a .vbs script and passed to execute, the contents
-' of the script are visible within the relevant scope of this script.
-function include(library_filename)
- dim filesystem_object, file
- set filesystem_object = createobject("scripting.filesystemobject")
- set file = filesystem_object.opentextfile(library_filename, READ_ONLY)
-
- include = file.readall
- set file = Nothing
- set filesystem_object = nothing
-end function
-
-execute include("common.vbs")
-
-' Required command line options.
-dim required_options, provided_options
-
-required_options = array("username")
-set provided_options = wscript.arguments.named
-
-set setup_options = new setup_object
-setup_options.check_options provided_options, required_options
-
-if setup_options.error_code = RTN_ERR then
- setup_options.list_missing_options
- stdout.writeline USAGE_STATEMENT
- wscript.quit(setup_options.error_code)
-end if
-
-username = provided_options.item("username")
-
-' Bind to the DC.
-set rootDSE = getobject("LDAP://rootDSE")
-Set container = getobject("LDAP://CN=Users," & _
- rootDSE.get("defaultNamingContext"))
-
-' Delete the user account.
-container.delete "User", "CN=" & username
Added: branches/SOC/bnh/ads_deluser.wsf
===================================================================
--- branches/SOC/bnh/ads_deluser.wsf 2006-06-03 19:22:54 UTC (rev 16032)
+++ branches/SOC/bnh/ads_deluser.wsf 2006-06-03 19:30:38 UTC (rev 16033)
@@ -0,0 +1,54 @@
+<package>
+<job id=ads_deluser>
+<script language="VBScript" src="common.vbs">
+
+' A windows script (.wsf) to remove an AD user, written in VBScript.
+' Copyright Brad Henry <brad at samba.org> 2006
+' Released under the GNU GPL v2 or later.
+
+const USAGE_STATEMENT = "Usage: cscript ads_deluser.vbs /username:<username>"
+
+on error resume next
+
+' Command line options.
+dim required_options, provided_options
+
+required_options = array("username")
+set provided_options = wscript.arguments.named
+
+set setup_options = new setup_object
+setup_options.check_options provided_options, required_options
+
+if setup_options.error_code = RTN_ERR then
+ setup_options.list_missing_options
+ stdout.writeline USAGE_STATEMENT
+ wscript.quit(setup_options.error_code)
+end if
+
+username = provided_options.item("username")
+
+' Bind to the DC.
+set rootDSE = getObject("LDAP://rootDSE")
+Set container = getObject("LDAP://CN=Users," _
+ & rootDSE.get("defaultNamingContext"))
+
+' Delete the user account.
+container.delete "User", "CN=" & username
+if err.number <> 0 then
+ if hex(err.number) = ADSI_ERROR_DS_NO_SUCH_OBJECT then
+ stdout.writeline "User account " & username _
+ & " does not exist."
+ report_error
+ wscript.quit(err.number)
+ else
+ stdout.writeline "An unhandled error occurred while removing " _
+ & " user account " & username & "."
+ report_error
+ wscript.quit(err.number)
+ end if
+end if
+stdout.writeline "User " & username & " deleted."
+
+</script>
+</job>
+</package>
More information about the samba-cvs
mailing list