'========================================================================== ' ' ' NAME: ' ' AUTHOR: Ed Wilson , MS ' DATE : 5/8/2006 ' ' COMMENT: '1.Based upon the createOU script, uses many of same variable names '2.Big difference is using user as class, and need to specify user name with cn '3.Use the put method to put information into attributes on the user. '========================================================================== Option Explicit On Error Resume next Dim strProvider 'defines how will talk. Dim strOU ' path to where new object will be created Dim strDomain 'name of strDomain connecting to Dim strClass ' the class of object we are creating Dim strOUname 'name of object are creating Dim objDomain 'holds connection to adsi Dim objOU 'holds handle to create method strProvider = "LDAP://" strOU = "OU=mred," 'when using is OU=mred, THE , would be required. strDomain = "dc=nwtraders,dc=msft" strClass = "User" strOUname = "CN=MyNewUser" Set objDomain = GetObject(strProvider & strOU & strDomain) WScript.echo strProvider & strOU & strDomain 'debug Set objOU = objDomain.create(strClass, strOUname) WScript.echo strClass & "," & strOUname 'debug objOU.Put "SAMAccountName", funfix(strOUname) objOU.SetInfo If Err.number = 0 Then WScript.Echo(strOUname & " was created") Else If Err.number = "-2147019886" Then WScript.echo strOUname & " already exists" Else WScript.echo " error on the play " & Err.Number End If End If Function funfix (strin) funfix = Mid(strin,4) 'removes cn= from username End function