Stupid VBScript/ADSI question 
Author Message
 Stupid VBScript/ADSI question

I am writing a VBScript to modify user(s) on an NT/2000 domain/AD

The following will create a specified user, in a specified Domain,
with a specified Loginscript.

The stupid question is...

How would I modify an existing Domain User?

I haven't been playing around much with VB/VBscript, so don't flame my
script too much

Dim oDomain
Dim oUser
dim sUserId

Dim oArgs
Dim ArgUser
Dim ArgDomain
Dim ArgLogonScript

Set oArgs = WScript.Arguments  

if oArgs.Count < 3 then
        ShowHelpMessage
        Wscript.quit(o)
End If

ArgUser = oArgs.Item(0)
ArgDomain = oArgs.Item(1)
ArgLoginScript = oArgs.Item(2)

Set oDomain = GetObject("WinNT://" + ArgDomain)
Set OUser = ODomain.Create("user",ArgUser)

oUser.LoginScript = ArgLoginScript
oUser.SetInfo

'Help Message
sub ShowHelpMessage
        Wscript.Echo
        WScript.Echo "Creates a new user in a specified Domain, with
specified logon script"
        Wscript.Echo "modifyusr [Username] [DOMAIN] [LOGON SCRIPT]"
End Sub



Mon, 10 Mar 2003 03:00:00 GMT  
 Stupid VBScript/ADSI question

Use GetObject to "bind" to the object, then manipulate the attributes using
the Put command.

Set oUser = GetObject("LDAP://CN="Jim Smith,CN=users,DC=mycorp,DC=com")

oUser.Put "givenName", "James"
oUser.SetInfo '--save changes

Jeff


Quote:
> I am writing a VBscript to modify user(s) on an NT/2000 domain/AD

> The following will create a specified user, in a specified Domain,
> with a specified Loginscript.

> The stupid question is...

> How would I modify an existing Domain User?

> I haven't been playing around much with VB/VBscript, so don't flame my
> script too much

> Dim oDomain
> Dim oUser
> dim sUserId

> Dim oArgs
> Dim ArgUser
> Dim ArgDomain
> Dim ArgLogonScript

> Set oArgs = WScript.Arguments

> if oArgs.Count < 3 then
> ShowHelpMessage
> Wscript.quit(o)
> End If

> ArgUser = oArgs.Item(0)
> ArgDomain = oArgs.Item(1)
> ArgLoginScript = oArgs.Item(2)

> Set oDomain = GetObject("WinNT://" + ArgDomain)
> Set OUser = ODomain.Create("user",ArgUser)

> oUser.LoginScript = ArgLoginScript
> oUser.SetInfo

> 'Help Message
> sub ShowHelpMessage
> Wscript.Echo
> WScript.Echo "Creates a new user in a specified Domain, with
> specified logon script"
> Wscript.Echo "modifyusr [Username] [DOMAIN] [LOGON SCRIPT]"
> End Sub



Mon, 10 Mar 2003 03:00:00 GMT  
 Stupid VBScript/ADSI question

Set oUser = GetObject("WinNT://" & ArgDomain & "/" & ArgUser)

oUser.LoginScript = ArgLoginScript
oUser.SetInfo

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> I am writing a VBscript to modify user(s) on an NT/2000 domain/AD

> The following will create a specified user, in a specified Domain,
> with a specified Loginscript.

> The stupid question is...

> How would I modify an existing Domain User?

> I haven't been playing around much with VB/VBscript, so don't flame my
> script too much

> Dim oDomain
> Dim oUser
> dim sUserId

> Dim oArgs
> Dim ArgUser
> Dim ArgDomain
> Dim ArgLogonScript

> Set oArgs = WScript.Arguments

> if oArgs.Count < 3 then
> ShowHelpMessage
> Wscript.quit(o)
> End If

> ArgUser = oArgs.Item(0)
> ArgDomain = oArgs.Item(1)
> ArgLoginScript = oArgs.Item(2)

> Set oDomain = GetObject("WinNT://" + ArgDomain)
> Set OUser = ODomain.Create("user",ArgUser)

> oUser.LoginScript = ArgLoginScript
> oUser.SetInfo

> 'Help Message
> sub ShowHelpMessage
> Wscript.Echo
> WScript.Echo "Creates a new user in a specified Domain, with
> specified logon script"
> Wscript.Echo "modifyusr [Username] [DOMAIN] [LOGON SCRIPT]"
> End Sub



Mon, 10 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Stupid VBScript/ADSI question

2. Stupid Stupid Question

3. VBScript, ADO, ASP: Yet Another Stupid Newbie Question

4. VBScript, ADO, ASP: Yet Another Stupid Newbie Question

5. Stupid question from a perhaps stupid beginner.

6. An ADSI and VBScript question

7. Maybe stupid question

8. process flow...stupid question im sure

9. The most stupid question on the planet!

10. Sorry for the (stupid) question

11. req: answer to stupid question.

12. stupid drop-down list question.....

 

 
Powered by phpBB® Forum Software