Problems with adding a user 
Author Message
 Problems with adding a user

    I am getting an error trying to add a user to my AD domain.  The script
works unless I try to specify that the account is not disabled.  I don't
want to have to go in and manually enable the account after it is created.
That would defeat the whole purpose of the quick and dirty user adder right?

Here is my user adding code.

Set objUser = objContainer.Create("user", "CN=" & sFullName)
If (Err.Number <> 0) Then
  BailOnFailure Err.Number, "on Create User method"
End If

objUser.Put "samAccountName", sUsername
objUser.SetInfo

'set new account properties
objUser.SetPassword(sPassword)
objUser.AccountDisabled(sDisabled)
objUser.Put "Description", sDescription
objUser.Put "LoginScript", sLogin
'objUser.Put "HomeDirectory", sHomeDir
'objUser.Put "HomeDirDrive", sHomeDrive
'objUser.Put "Profile", sProfile

' save userobject properties
objUser.SetInfo

It gives me an error stating that the AccountDisabled property is not
supported by this object.  This is the same error I was getting on the
password string until I changed it to specify the variable in parenthesis.
The user account is created by the first setinfo statement, but the
properties below it are never set due to the accountdisabled error.
The variable in the script looks like this

sDisabled = False

Can someone help me out here?  It says in 2 of my scripting books that the
AccountDisabled property is a boolean value that can be set to false.
HELP!!

Ryan



Tue, 14 Dec 2004 03:50:50 GMT  
 Problems with adding a user
I've had problems with that before also.  Here's what seemed to work...

(1) Scratch the AccountDisabled entry you have now.

(2) Immediately AFTER the objUser.SetInfo line, add this:

objUser.AccountDisabled=false
objUser.SetInfo

I think there's something that hiccups if you try to add the non-disabled info
during the account creation phase.


Quote:
>     I am getting an error trying to add a user to my AD domain.  The script
> works unless I try to specify that the account is not disabled.  I don't
> want to have to go in and manually enable the account after it is created.
> That would defeat the whole purpose of the quick and dirty user adder right?

> Here is my user adding code.

> Set objUser = objContainer.Create("user", "CN=" & sFullName)
> If (Err.Number <> 0) Then
>   BailOnFailure Err.Number, "on Create User method"
> End If

> objUser.Put "samAccountName", sUsername
> objUser.SetInfo

> 'set new account properties
> objUser.SetPassword(sPassword)
> objUser.AccountDisabled(sDisabled)
> objUser.Put "Description", sDescription
> objUser.Put "LoginScript", sLogin
> 'objUser.Put "HomeDirectory", sHomeDir
> 'objUser.Put "HomeDirDrive", sHomeDrive
> 'objUser.Put "Profile", sProfile

> ' save userobject properties
> objUser.SetInfo

> It gives me an error stating that the AccountDisabled property is not
> supported by this object.  This is the same error I was getting on the
> password string until I changed it to specify the variable in parenthesis.
> The user account is created by the first setinfo statement, but the
> properties below it are never set due to the accountdisabled error.
> The variable in the script looks like this

> sDisabled = False

> Can someone help me out here?  It says in 2 of my scripting books that the
> AccountDisabled property is a boolean value that can be set to false.
> HELP!!

> Ryan



Tue, 14 Dec 2004 04:05:58 GMT  
 Problems with adding a user
    Do you usually have lots of problems setting these properties?  I have
been struggling with almost every one of them.



Quote:
> I've had problems with that before also.  Here's what seemed to work...

> (1) Scratch the AccountDisabled entry you have now.

> (2) Immediately AFTER the objUser.SetInfo line, add this:

> objUser.AccountDisabled=false
> objUser.SetInfo

> I think there's something that hiccups if you try to add the non-disabled
info
> during the account creation phase.



> >     I am getting an error trying to add a user to my AD domain.  The
script
> > works unless I try to specify that the account is not disabled.  I don't
> > want to have to go in and manually enable the account after it is
created.
> > That would defeat the whole purpose of the quick and dirty user adder
right?

> > Here is my user adding code.

> > Set objUser = objContainer.Create("user", "CN=" & sFullName)
> > If (Err.Number <> 0) Then
> >   BailOnFailure Err.Number, "on Create User method"
> > End If

> > objUser.Put "samAccountName", sUsername
> > objUser.SetInfo

> > 'set new account properties
> > objUser.SetPassword(sPassword)
> > objUser.AccountDisabled(sDisabled)
> > objUser.Put "Description", sDescription
> > objUser.Put "LoginScript", sLogin
> > 'objUser.Put "HomeDirectory", sHomeDir
> > 'objUser.Put "HomeDirDrive", sHomeDrive
> > 'objUser.Put "Profile", sProfile

> > ' save userobject properties
> > objUser.SetInfo

> > It gives me an error stating that the AccountDisabled property is not
> > supported by this object.  This is the same error I was getting on the
> > password string until I changed it to specify the variable in
parenthesis.
> > The user account is created by the first setinfo statement, but the
> > properties below it are never set due to the accountdisabled error.
> > The variable in the script looks like this

> > sDisabled = False

> > Can someone help me out here?  It says in 2 of my scripting books that
the
> > AccountDisabled property is a boolean value that can be set to false.
> > HELP!!

> > Ryan



Wed, 15 Dec 2004 01:11:10 GMT  
 Problems with adding a user
I've had some.  The causes are various.  Here are a few general "principles"
which help to remember.

(1) Certain ADSI attributes are required, and you can't create objects without
them.

(2) If you try reading optional properties, always remember that the object you
are accessing might not have that attribute.  If it doesn't, the attribute won't
be empty - it will actually not even exist, so it will throw an error which you
need to trap.

(3) Names of attributes as displayed in AD Users and Computers have nothing at
all to do with the ADSI attribute names.

(4) Some attributes may require that you use methods such as PutEx to stuff them
in place.


Quote:
>     Do you usually have lots of problems setting these properties?  I have
> been struggling with almost every one of them.



> > I've had problems with that before also.  Here's what seemed to work...

> > (1) Scratch the AccountDisabled entry you have now.

> > (2) Immediately AFTER the objUser.SetInfo line, add this:

> > objUser.AccountDisabled=false
> > objUser.SetInfo

> > I think there's something that hiccups if you try to add the non-disabled
> info
> > during the account creation phase.



> > >     I am getting an error trying to add a user to my AD domain.  The
> script
> > > works unless I try to specify that the account is not disabled.  I don't
> > > want to have to go in and manually enable the account after it is
> created.
> > > That would defeat the whole purpose of the quick and dirty user adder
> right?

> > > Here is my user adding code.

> > > Set objUser = objContainer.Create("user", "CN=" & sFullName)
> > > If (Err.Number <> 0) Then
> > >   BailOnFailure Err.Number, "on Create User method"
> > > End If

> > > objUser.Put "samAccountName", sUsername
> > > objUser.SetInfo

> > > 'set new account properties
> > > objUser.SetPassword(sPassword)
> > > objUser.AccountDisabled(sDisabled)
> > > objUser.Put "Description", sDescription
> > > objUser.Put "LoginScript", sLogin
> > > 'objUser.Put "HomeDirectory", sHomeDir
> > > 'objUser.Put "HomeDirDrive", sHomeDrive
> > > 'objUser.Put "Profile", sProfile

> > > ' save userobject properties
> > > objUser.SetInfo

> > > It gives me an error stating that the AccountDisabled property is not
> > > supported by this object.  This is the same error I was getting on the
> > > password string until I changed it to specify the variable in
> parenthesis.
> > > The user account is created by the first setinfo statement, but the
> > > properties below it are never set due to the accountdisabled error.
> > > The variable in the script looks like this

> > > sDisabled = False

> > > Can someone help me out here?  It says in 2 of my scripting books that
> the
> > > AccountDisabled property is a boolean value that can be set to false.
> > > HELP!!

> > > Ryan



Wed, 15 Dec 2004 02:07:13 GMT  
 Problems with adding a user
Could it be a problem similar to programmatically unlocking an account? The
LDAP provider can't be used to do this
(http://support.microsoft.com/default.aspx?scid=kb;en-us;Q250873). Basically
the LDAP provider won't work because the IsAccountLocked value is not stored
in the AD, but is created on the fly when accessed throught the WinNT
provider. The fix is to use the WinNT provider.

Quote:
>     I am getting an error trying to add a user to my AD domain.  The
script
> works unless I try to specify that the account is not disabled.  I don't
> want to have to go in and manually enable the account after it is created.
> That would defeat the whole purpose of the quick and dirty user adder
right?

> Here is my user adding code.

> Set objUser = objContainer.Create("user", "CN=" & sFullName)
> If (Err.Number <> 0) Then
>   BailOnFailure Err.Number, "on Create User method"
> End If

> objUser.Put "samAccountName", sUsername
> objUser.SetInfo

> 'set new account properties
> objUser.SetPassword(sPassword)
> objUser.AccountDisabled(sDisabled)
> objUser.Put "Description", sDescription
> objUser.Put "LoginScript", sLogin
> 'objUser.Put "HomeDirectory", sHomeDir
> 'objUser.Put "HomeDirDrive", sHomeDrive
> 'objUser.Put "Profile", sProfile

> ' save userobject properties
> objUser.SetInfo

> It gives me an error stating that the AccountDisabled property is not
> supported by this object.  This is the same error I was getting on the
> password string until I changed it to specify the variable in parenthesis.
> The user account is created by the first setinfo statement, but the
> properties below it are never set due to the accountdisabled error.
> The variable in the script looks like this

> sDisabled = False

> Can someone help me out here?  It says in 2 of my scripting books that the
> AccountDisabled property is a boolean value that can be set to false.
> HELP!!

> Ryan



Fri, 24 Dec 2004 20:58:52 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Adding users with VBScript - obscure problem

2. adding user account to "Users" container

3. adding users to "Users" container

4. Add Domain Users Group to Powe Users Group in Script

5. Adding users from IIS5

6. Adding User and outing Info

7. "add users and groups" interface

8. "add users and groups" interface

9. script to add and delete users

10. Add User to Group on Computers

11. Adding a user to a group on WinNT

12. Adding/Deleting users to windows 2000 Database

 

 
Powered by phpBB® Forum Software