create user on AD server

Hi,
I want to create an application which on passing a user id & password will 
create that user on windows 2003 AD server. I used netuseradd API to do this, 
but was not able to create user on AD server & boot my system with that user. 
CAn anybody please help me do this. if i am doing right what could be the 
problem. i am getting unknown user type error. i found few scripts but they 
need to be run on server itself not on remote system in network.

Thanks
0
Utf
7/29/2010 6:13:25 PM
vb.general.discussion 1016 articles. 0 followers. Follow

12 Replies
1521 Views

Similar Articles

[PageSpeed] 44

On Thu, 29 Jul 2010 11:13:25 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:

� Hi,
� I want to create an application which on passing a user id & password will 
� create that user on windows 2003 AD server. I used netuseradd API to do this, 
� but was not able to create user on AD server & boot my system with that user. 
� CAn anybody please help me do this. if i am doing right what could be the 
� problem. i am getting unknown user type error. i found few scripts but they 
� need to be run on server itself not on remote system in network.
� 
� Thanks

A little more detail would help. Are you creating a domain user or a system local user? Does the
error occur when you attempt to log on to the server interactively? What is the exact error message?


Paul
~~~~
Microsoft MVP (Visual Basic)
0
Paul
7/29/2010 7:01:00 PM
Dipesh_Sharma wrote:
> Hi,
> I want to create an application which on passing a user id &
> password will create that user on windows 2003 AD server. I used
> netuseradd API to do this, but was not able to create user on AD
> server & boot my system with that user. CAn anybody please help me
> do this. if i am doing right what could be the problem. i am
> getting unknown user type error. i found few scripts but they need
> to be run on server itself not on remote system in network.

Perhaps you could post the VB6 code you're using now, and we can spot
a problem...

-- 
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"

0
Jim
7/29/2010 8:04:11 PM
Hi Paul,
Thnx for replying. I am creating a domain user on msd.com, not a local user 
on client machine, through a client machine with following code. Sometime the 
error was related to path not found, and sometime logon failure. Please 
review the code and correct it so that it can create the user on windows 
server.
I am using following code:::::
xi_strServerName = "virtual-server"  'netbios name, i also used domain name 
msd.com here
xi_strUserName = "newuser"
xi_strUserFullName = "test newuser"
xi_strPassword = "user@123"
xi_strUserComment = "test user"
p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
WriteLog "staging in AD user..."
' ------------------------------------------
    ' Create byte arrays to avoid Unicode hassles
    ' ------------------------------------------
    p_abytServerName = xi_strServerName & vbNullChar
    p_abytUserName = xi_strUserName & vbNullChar
    p_abytUserFullName = xi_strUserFullName & vbNullChar
    p_abytPassword = xi_strPassword & vbNullChar
    p_abytUserComment = xi_strUserComment & vbNullChar
    ' ------------------------------------------
    ' Get pointers to the byte arrays
    ' ------------------------------------------
    p_lngPtrUserName = VarPtr(p_abytUserName(0))
    p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
    p_lngPtrPassword = VarPtr(p_abytPassword(0))
    p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
With p_typUserInfo3
      .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
      .usri3_comment = p_lngPtrUserComment ' Comment
      .usri3_flags = p_lngFlags ' There are a number of variations
      .usri3_full_name = p_lngPtrUserFullName ' User's full name
      .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any amount of 
disk space
      .usri3_name = p_lngPtrUserName ' Name of user account
      .usri3_password = p_lngPtrPassword ' Password for user account
      .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST use this 
constant for NetUserAdd
      .usri3_script_path = 0&       ' Path of user's logon script
      .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
      .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
      .usri3_code_page = 0&         ' Code page for user's language
      .usri3_country_code = 0&      ' Country code for user's language
      .usri3_home_dir = 0&          ' Can specify path of home directory of 
this
      'user
      .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
      'profile
      .usri3_last_logoff = 0&       ' Not needed when adding a user
      .usri3_last_logon = 0&        ' Ignored by NetUserAdd
      .usri3_logon_hours = 0&       ' Null means no restrictions
      .usri3_logon_server = 0&      ' Null means logon to domain server
      .usri3_num_logons = 0&        ' Ignored by NetUserAdd
      .usri3_parms = 0&             ' Used by specific applications
      .usri3_password_age = 0&      ' Ignored by NetUserAdd
      .usri3_password_expired = 0&  ' None-zero means user must change 
password at next logon
      .usri3_priv = 0&              ' Ignored by NetUserAdd
      .usri3_profile = 0&           ' Path to a user's profile
      .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
      .usri3_user_id = 0&           ' Ignored by NetUserAdd
      .usri3_usr_comment = 0&       ' User comment
      .usri3_workstations = 0&      ' Workstations a user can log onto (null 
= all stations)
    End With
    WriteLog "creating AD user from NetUserAdd..."
    Dim objComputer
    Dim strComputer As String
    
    p_lngRtn = NetUserAdd(p_abytServerName(0), _
    3, p_typUserInfo3, p_lngParamErr)

'code ends

"Paul Clement" wrote:

> On Thu, 29 Jul 2010 11:13:25 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:
> 
> ¤ Hi,
> ¤ I want to create an application which on passing a user id & password will 
> ¤ create that user on windows 2003 AD server. I used netuseradd API to do this, 
> ¤ but was not able to create user on AD server & boot my system with that user. 
> ¤ CAn anybody please help me do this. if i am doing right what could be the 
> ¤ problem. i am getting unknown user type error. i found few scripts but they 
> ¤ need to be run on server itself not on remote system in network.
> ¤ 
> ¤ Thanks
> 
> A little more detail would help. Are you creating a domain user or a system local user? Does the
> error occur when you attempt to log on to the server interactively? What is the exact error message?
> 
> 
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
> .
> 
0
Utf
8/1/2010 6:24:04 PM
Hi Jim,
Thnx for replying. I am creating a domain user on msd.com through a client 
machine with following code. Please review the code and correct it so that it 
can create the user on windows server.
I am using following code:::::
xi_strServerName = "virtual-server"  'netbios name, i also used domain name 
msd.com here
xi_strUserName = "newuser"
xi_strUserFullName = "test newuser"
xi_strPassword = "user@123"
xi_strUserComment = "test user"
p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
WriteLog "staging in AD user..."
' ------------------------------------------
    ' Create byte arrays to avoid Unicode hassles
    ' ------------------------------------------
    p_abytServerName = xi_strServerName & vbNullChar
    p_abytUserName = xi_strUserName & vbNullChar
    p_abytUserFullName = xi_strUserFullName & vbNullChar
    p_abytPassword = xi_strPassword & vbNullChar
    p_abytUserComment = xi_strUserComment & vbNullChar
    ' ------------------------------------------
    ' Get pointers to the byte arrays
    ' ------------------------------------------
    p_lngPtrUserName = VarPtr(p_abytUserName(0))
    p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
    p_lngPtrPassword = VarPtr(p_abytPassword(0))
    p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
With p_typUserInfo3
      .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
      .usri3_comment = p_lngPtrUserComment ' Comment
      .usri3_flags = p_lngFlags ' There are a number of variations
      .usri3_full_name = p_lngPtrUserFullName ' User's full name
      .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any amount of 
disk space
      .usri3_name = p_lngPtrUserName ' Name of user account
      .usri3_password = p_lngPtrPassword ' Password for user account
      .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST use this 
constant for NetUserAdd
      .usri3_script_path = 0&       ' Path of user's logon script
      .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
      .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
      .usri3_code_page = 0&         ' Code page for user's language
      .usri3_country_code = 0&      ' Country code for user's language
      .usri3_home_dir = 0&          ' Can specify path of home directory of 
this
      'user
      .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
      'profile
      .usri3_last_logoff = 0&       ' Not needed when adding a user
      .usri3_last_logon = 0&        ' Ignored by NetUserAdd
      .usri3_logon_hours = 0&       ' Null means no restrictions
      .usri3_logon_server = 0&      ' Null means logon to domain server
      .usri3_num_logons = 0&        ' Ignored by NetUserAdd
      .usri3_parms = 0&             ' Used by specific applications
      .usri3_password_age = 0&      ' Ignored by NetUserAdd
      .usri3_password_expired = 0&  ' None-zero means user must change 
password at next logon
      .usri3_priv = 0&              ' Ignored by NetUserAdd
      .usri3_profile = 0&           ' Path to a user's profile
      .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
      .usri3_user_id = 0&           ' Ignored by NetUserAdd
      .usri3_usr_comment = 0&       ' User comment
      .usri3_workstations = 0&      ' Workstations a user can log onto (null 
= all stations)
    End With
    WriteLog "creating AD user from NetUserAdd..."
    Dim objComputer
    Dim strComputer As String
    
    p_lngRtn = NetUserAdd(p_abytServerName(0), _
    3, p_typUserInfo3, p_lngParamErr)

'code ends

"Jim Mack" wrote:

> Dipesh_Sharma wrote:
> > Hi,
> > I want to create an application which on passing a user id &
> > password will create that user on windows 2003 AD server. I used
> > netuseradd API to do this, but was not able to create user on AD
> > server & boot my system with that user. CAn anybody please help me
> > do this. if i am doing right what could be the problem. i am
> > getting unknown user type error. i found few scripts but they need
> > to be run on server itself not on remote system in network.
> 
> Perhaps you could post the VB6 code you're using now, and we can spot
> a problem...
> 
> -- 
>    Jim Mack
>    Twisted tees at http://www.cafepress.com/2050inc
>    "We sew confusion"
> 
> .
> 
0
Utf
8/1/2010 6:26:03 PM
Dipesh_Sharma wrote:

We need to see your Declare for NetUserAdd -- are you using the -W
version of that API? Because from the look of it you're passing
Unicode string params in the byte arrays. Also, show us your Type
statements for the structure(s) you're passing.
-- 
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"

> Hi Jim,
> Thnx for replying. I am creating a domain user on msd.com through a
> client machine with following code. Please review the code and
> correct it so that it can create the user on windows server.
> I am using following code:::::
> xi_strServerName = "virtual-server"  'netbios name, i also used
> domain name msd.com here
> xi_strUserName = "newuser"
> xi_strUserFullName = "test newuser"
> xi_strPassword = "user@123"
> xi_strUserComment = "test user"
> p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
> WriteLog "staging in AD user..."
> ' ------------------------------------------
>     ' Create byte arrays to avoid Unicode hassles
>     ' ------------------------------------------
>     p_abytServerName = xi_strServerName & vbNullChar
>     p_abytUserName = xi_strUserName & vbNullChar
>     p_abytUserFullName = xi_strUserFullName & vbNullChar
>     p_abytPassword = xi_strPassword & vbNullChar
>     p_abytUserComment = xi_strUserComment & vbNullChar
>     ' ------------------------------------------
>     ' Get pointers to the byte arrays
>     ' ------------------------------------------
>     p_lngPtrUserName = VarPtr(p_abytUserName(0))
>     p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
>     p_lngPtrPassword = VarPtr(p_abytPassword(0))
>     p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
> With p_typUserInfo3
>       .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
>       .usri3_comment = p_lngPtrUserComment ' Comment
>       .usri3_flags = p_lngFlags ' There are a number of variations
>       .usri3_full_name = p_lngPtrUserFullName ' User's full name
>       .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any
> amount of disk space
>       .usri3_name = p_lngPtrUserName ' Name of user account
>       .usri3_password = p_lngPtrPassword ' Password for user account
>       .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST
> use this constant for NetUserAdd
>       .usri3_script_path = 0&       ' Path of user's logon script
>       .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
>       .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
>       .usri3_code_page = 0&         ' Code page for user's language
>       .usri3_country_code = 0&      ' Country code for user's
>       language .usri3_home_dir = 0&          ' Can specify path of
> home directory of this
>       'user
>       .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
>       'profile
>       .usri3_last_logoff = 0&       ' Not needed when adding a user
>       .usri3_last_logon = 0&        ' Ignored by NetUserAdd
>       .usri3_logon_hours = 0&       ' Null means no restrictions
>       .usri3_logon_server = 0&      ' Null means logon to domain
>       server .usri3_num_logons = 0&        ' Ignored by NetUserAdd
>       .usri3_parms = 0&             ' Used by specific applications
>       .usri3_password_age = 0&      ' Ignored by NetUserAdd
>       .usri3_password_expired = 0&  ' None-zero means user must
> change password at next logon
>       .usri3_priv = 0&              ' Ignored by NetUserAdd
>       .usri3_profile = 0&           ' Path to a user's profile
>       .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
>       .usri3_user_id = 0&           ' Ignored by NetUserAdd
>       .usri3_usr_comment = 0&       ' User comment
>       .usri3_workstations = 0&      ' Workstations a user can log
> onto (null = all stations)
>     End With
>     WriteLog "creating AD user from NetUserAdd..."
>     Dim objComputer
>     Dim strComputer As String
>
>     p_lngRtn = NetUserAdd(p_abytServerName(0), _
>     3, p_typUserInfo3, p_lngParamErr)
>
> 'code ends
>
> "Jim Mack" wrote:
>
>> Dipesh_Sharma wrote:
>>> Hi,
>>> I want to create an application which on passing a user id &
>>> password will create that user on windows 2003 AD server. I used
>>> netuseradd API to do this, but was not able to create user on AD
>>> server & boot my system with that user. CAn anybody please help me
>>> do this. if i am doing right what could be the problem. i am
>>> getting unknown user type error. i found few scripts but they need
>>> to be run on server itself not on remote system in network.
>>
>> Perhaps you could post the VB6 code you're using now, and we can
>> spot a problem...
>>
>> --
>>    Jim Mack
>>    Twisted tees at http://www.cafepress.com/2050inc
>>    "We sew confusion"
>>
>> .

0
Jim
8/1/2010 9:05:41 PM
On Sun, 1 Aug 2010 11:24:04 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:


I prefer using ADSI. It's much easier than using API function calls:

http://www.15seconds.com/issue/011005.htm


Paul
~~~~
Microsoft MVP (Visual Basic)
0
Paul
8/2/2010 4:38:46 PM
Hi Paul,
I have also gone through this link. Can you please confirm, whether i can 
use this code as it is, or i need to add anything else also in my code? like 
any other library etc?
This site has following code to create user:
#Sub AddUser(strUser,strDomain,strFullname,strPassword,strDesc)
#Dim Computer
#Dim User
#Set Computer = Getobject("WinNT://" & strDomain)
#Set User = computer.create("User",strUser)
Can i run this code from my client machine, instead of server itself? and 
what do i need to pass to strDomain? my domain name is "msd.com" so should i 
pass this complete string or server's netbios name?


"Paul Clement" wrote:

> On Sun, 1 Aug 2010 11:24:04 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:
> 
> 
> I prefer using ADSI. It's much easier than using API function calls:
> 
> http://www.15seconds.com/issue/011005.htm
> 
> 
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
> .
> 
0
Utf
8/2/2010 5:56:06 PM
Hi Jim,
i will update you on declaration of API. But can you please post your own 
code that works well to create user on AD server(msd.com) from client machine.
One more thing Jim, we need to have Admin rights for managing AD, but we are 
not using admin user here, so will it work fine?

"Jim Mack" wrote:

> Dipesh_Sharma wrote:
> 
> We need to see your Declare for NetUserAdd -- are you using the -W
> version of that API? Because from the look of it you're passing
> Unicode string params in the byte arrays. Also, show us your Type
> statements for the structure(s) you're passing.
> -- 
>    Jim Mack
>    Twisted tees at http://www.cafepress.com/2050inc
>    "We sew confusion"
> 
> > Hi Jim,
> > Thnx for replying. I am creating a domain user on msd.com through a
> > client machine with following code. Please review the code and
> > correct it so that it can create the user on windows server.
> > I am using following code:::::
> > xi_strServerName = "virtual-server"  'netbios name, i also used
> > domain name msd.com here
> > xi_strUserName = "newuser"
> > xi_strUserFullName = "test newuser"
> > xi_strPassword = "user@123"
> > xi_strUserComment = "test user"
> > p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
> > WriteLog "staging in AD user..."
> > ' ------------------------------------------
> >     ' Create byte arrays to avoid Unicode hassles
> >     ' ------------------------------------------
> >     p_abytServerName = xi_strServerName & vbNullChar
> >     p_abytUserName = xi_strUserName & vbNullChar
> >     p_abytUserFullName = xi_strUserFullName & vbNullChar
> >     p_abytPassword = xi_strPassword & vbNullChar
> >     p_abytUserComment = xi_strUserComment & vbNullChar
> >     ' ------------------------------------------
> >     ' Get pointers to the byte arrays
> >     ' ------------------------------------------
> >     p_lngPtrUserName = VarPtr(p_abytUserName(0))
> >     p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
> >     p_lngPtrPassword = VarPtr(p_abytPassword(0))
> >     p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
> > With p_typUserInfo3
> >       .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
> >       .usri3_comment = p_lngPtrUserComment ' Comment
> >       .usri3_flags = p_lngFlags ' There are a number of variations
> >       .usri3_full_name = p_lngPtrUserFullName ' User's full name
> >       .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any
> > amount of disk space
> >       .usri3_name = p_lngPtrUserName ' Name of user account
> >       .usri3_password = p_lngPtrPassword ' Password for user account
> >       .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST
> > use this constant for NetUserAdd
> >       .usri3_script_path = 0&       ' Path of user's logon script
> >       .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
> >       .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
> >       .usri3_code_page = 0&         ' Code page for user's language
> >       .usri3_country_code = 0&      ' Country code for user's
> >       language .usri3_home_dir = 0&          ' Can specify path of
> > home directory of this
> >       'user
> >       .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
> >       'profile
> >       .usri3_last_logoff = 0&       ' Not needed when adding a user
> >       .usri3_last_logon = 0&        ' Ignored by NetUserAdd
> >       .usri3_logon_hours = 0&       ' Null means no restrictions
> >       .usri3_logon_server = 0&      ' Null means logon to domain
> >       server .usri3_num_logons = 0&        ' Ignored by NetUserAdd
> >       .usri3_parms = 0&             ' Used by specific applications
> >       .usri3_password_age = 0&      ' Ignored by NetUserAdd
> >       .usri3_password_expired = 0&  ' None-zero means user must
> > change password at next logon
> >       .usri3_priv = 0&              ' Ignored by NetUserAdd
> >       .usri3_profile = 0&           ' Path to a user's profile
> >       .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
> >       .usri3_user_id = 0&           ' Ignored by NetUserAdd
> >       .usri3_usr_comment = 0&       ' User comment
> >       .usri3_workstations = 0&      ' Workstations a user can log
> > onto (null = all stations)
> >     End With
> >     WriteLog "creating AD user from NetUserAdd..."
> >     Dim objComputer
> >     Dim strComputer As String
> >
> >     p_lngRtn = NetUserAdd(p_abytServerName(0), _
> >     3, p_typUserInfo3, p_lngParamErr)
> >
> > 'code ends
> >
> > "Jim Mack" wrote:
> >
> >> Dipesh_Sharma wrote:
> >>> Hi,
> >>> I want to create an application which on passing a user id &
> >>> password will create that user on windows 2003 AD server. I used
> >>> netuseradd API to do this, but was not able to create user on AD
> >>> server & boot my system with that user. CAn anybody please help me
> >>> do this. if i am doing right what could be the problem. i am
> >>> getting unknown user type error. i found few scripts but they need
> >>> to be run on server itself not on remote system in network.
> >>
> >> Perhaps you could post the VB6 code you're using now, and we can
> >> spot a problem...
> >>
> >> --
> >>    Jim Mack
> >>    Twisted tees at http://www.cafepress.com/2050inc
> >>    "We sew confusion"
> >>
> >> .
> 
> .
> 
0
Utf
8/2/2010 6:00:03 PM
On Mon, 2 Aug 2010 10:56:06 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:

� Hi Paul,
� I have also gone through this link. Can you please confirm, whether i can 
� use this code as it is, or i need to add anything else also in my code? like 
� any other library etc?
� This site has following code to create user:
� #Sub AddUser(strUser,strDomain,strFullname,strPassword,strDesc)
� #Dim Computer
� #Dim User
� #Set Computer = Getobject("WinNT://" & strDomain)
� #Set User = computer.create("User",strUser)
� Can i run this code from my client machine, instead of server itself? and 
� what do i need to pass to strDomain? my domain name is "msd.com" so should i 
� pass this complete string or server's netbios name?

If your client machine is in the Active Directory domain that you want to add the users to then it
shouldn't be a problem. It doesn't look like there is anything else you would need to do from what I
can see in the code. It's just a matter of being in the same domain and having sufficient
permissions. All of library references are late bound.

The following code will get you the short domain name:

Set objSystemInfo = CreateObject("ADSystemInfo")
strDomain = objSystemInfo.DomainShortName


Paul
~~~~
Microsoft MVP (Visual Basic)
0
Paul
8/2/2010 7:46:19 PM
Hi Jim,

Here is my declaration: Private Declare Function NetUserAdd _
Lib "netapi32.dll" (servername As Byte, _
ByVal level As Long, Buffer As USER_INFO_3, _
parm_err As Long) As Long

"Jim Mack" wrote:

> Dipesh_Sharma wrote:
> 
> We need to see your Declare for NetUserAdd -- are you using the -W
> version of that API? Because from the look of it you're passing
> Unicode string params in the byte arrays. Also, show us your Type
> statements for the structure(s) you're passing.
> -- 
>    Jim Mack
>    Twisted tees at http://www.cafepress.com/2050inc
>    "We sew confusion"
> 
> > Hi Jim,
> > Thnx for replying. I am creating a domain user on msd.com through a
> > client machine with following code. Please review the code and
> > correct it so that it can create the user on windows server.
> > I am using following code:::::
> > xi_strServerName = "virtual-server"  'netbios name, i also used
> > domain name msd.com here
> > xi_strUserName = "newuser"
> > xi_strUserFullName = "test newuser"
> > xi_strPassword = "user@123"
> > xi_strUserComment = "test user"
> > p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
> > WriteLog "staging in AD user..."
> > ' ------------------------------------------
> >     ' Create byte arrays to avoid Unicode hassles
> >     ' ------------------------------------------
> >     p_abytServerName = xi_strServerName & vbNullChar
> >     p_abytUserName = xi_strUserName & vbNullChar
> >     p_abytUserFullName = xi_strUserFullName & vbNullChar
> >     p_abytPassword = xi_strPassword & vbNullChar
> >     p_abytUserComment = xi_strUserComment & vbNullChar
> >     ' ------------------------------------------
> >     ' Get pointers to the byte arrays
> >     ' ------------------------------------------
> >     p_lngPtrUserName = VarPtr(p_abytUserName(0))
> >     p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
> >     p_lngPtrPassword = VarPtr(p_abytPassword(0))
> >     p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
> > With p_typUserInfo3
> >       .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
> >       .usri3_comment = p_lngPtrUserComment ' Comment
> >       .usri3_flags = p_lngFlags ' There are a number of variations
> >       .usri3_full_name = p_lngPtrUserFullName ' User's full name
> >       .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any
> > amount of disk space
> >       .usri3_name = p_lngPtrUserName ' Name of user account
> >       .usri3_password = p_lngPtrPassword ' Password for user account
> >       .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST
> > use this constant for NetUserAdd
> >       .usri3_script_path = 0&       ' Path of user's logon script
> >       .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
> >       .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
> >       .usri3_code_page = 0&         ' Code page for user's language
> >       .usri3_country_code = 0&      ' Country code for user's
> >       language .usri3_home_dir = 0&          ' Can specify path of
> > home directory of this
> >       'user
> >       .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
> >       'profile
> >       .usri3_last_logoff = 0&       ' Not needed when adding a user
> >       .usri3_last_logon = 0&        ' Ignored by NetUserAdd
> >       .usri3_logon_hours = 0&       ' Null means no restrictions
> >       .usri3_logon_server = 0&      ' Null means logon to domain
> >       server .usri3_num_logons = 0&        ' Ignored by NetUserAdd
> >       .usri3_parms = 0&             ' Used by specific applications
> >       .usri3_password_age = 0&      ' Ignored by NetUserAdd
> >       .usri3_password_expired = 0&  ' None-zero means user must
> > change password at next logon
> >       .usri3_priv = 0&              ' Ignored by NetUserAdd
> >       .usri3_profile = 0&           ' Path to a user's profile
> >       .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
> >       .usri3_user_id = 0&           ' Ignored by NetUserAdd
> >       .usri3_usr_comment = 0&       ' User comment
> >       .usri3_workstations = 0&      ' Workstations a user can log
> > onto (null = all stations)
> >     End With
> >     WriteLog "creating AD user from NetUserAdd..."
> >     Dim objComputer
> >     Dim strComputer As String
> >
> >     p_lngRtn = NetUserAdd(p_abytServerName(0), _
> >     3, p_typUserInfo3, p_lngParamErr)
> >
> > 'code ends
> >
> > "Jim Mack" wrote:
> >
> >> Dipesh_Sharma wrote:
> >>> Hi,
> >>> I want to create an application which on passing a user id &
> >>> password will create that user on windows 2003 AD server. I used
> >>> netuseradd API to do this, but was not able to create user on AD
> >>> server & boot my system with that user. CAn anybody please help me
> >>> do this. if i am doing right what could be the problem. i am
> >>> getting unknown user type error. i found few scripts but they need
> >>> to be run on server itself not on remote system in network.
> >>
> >> Perhaps you could post the VB6 code you're using now, and we can
> >> spot a problem...
> >>
> >> --
> >>    Jim Mack
> >>    Twisted tees at http://www.cafepress.com/2050inc
> >>    "We sew confusion"
> >>
> >> .
> 
> .
> 
0
Utf
8/3/2010 5:20:06 PM
Hi Paul,
Thanks for your kind support, i am now able to create user on AD server.
I followed that site only and was able to easily achieve my requirement.

Thanks again :)

"Paul Clement" wrote:

> On Mon, 2 Aug 2010 10:56:06 -0700, Dipesh_Sharma <DipeshSharma@discussions.microsoft.com> wrote:
> 
> ¤ Hi Paul,
> ¤ I have also gone through this link. Can you please confirm, whether i can 
> ¤ use this code as it is, or i need to add anything else also in my code? like 
> ¤ any other library etc?
> ¤ This site has following code to create user:
> ¤ #Sub AddUser(strUser,strDomain,strFullname,strPassword,strDesc)
> ¤ #Dim Computer
> ¤ #Dim User
> ¤ #Set Computer = Getobject("WinNT://" & strDomain)
> ¤ #Set User = computer.create("User",strUser)
> ¤ Can i run this code from my client machine, instead of server itself? and 
> ¤ what do i need to pass to strDomain? my domain name is "msd.com" so should i 
> ¤ pass this complete string or server's netbios name?
> 
> If your client machine is in the Active Directory domain that you want to add the users to then it
> shouldn't be a problem. It doesn't look like there is anything else you would need to do from what I
> can see in the code. It's just a matter of being in the same domain and having sufficient
> permissions. All of library references are late bound.
> 
> The following code will get you the short domain name:
> 
> Set objSystemInfo = CreateObject("ADSystemInfo")
> strDomain = objSystemInfo.DomainShortName
> 
> 
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
> .
> 
0
Utf
8/6/2010 11:30:03 AM
Hi Jim,
I was able to create user on AD server through site that Paul suggested. 
Thanks for your support and guidance.

Thanks & Regards,
Dipesh

"Jim Mack" wrote:

> Dipesh_Sharma wrote:
> 
> We need to see your Declare for NetUserAdd -- are you using the -W
> version of that API? Because from the look of it you're passing
> Unicode string params in the byte arrays. Also, show us your Type
> statements for the structure(s) you're passing.
> -- 
>    Jim Mack
>    Twisted tees at http://www.cafepress.com/2050inc
>    "We sew confusion"
> 
> > Hi Jim,
> > Thnx for replying. I am creating a domain user on msd.com through a
> > client machine with following code. Please review the code and
> > correct it so that it can create the user on windows server.
> > I am using following code:::::
> > xi_strServerName = "virtual-server"  'netbios name, i also used
> > domain name msd.com here
> > xi_strUserName = "newuser"
> > xi_strUserFullName = "test newuser"
> > xi_strPassword = "user@123"
> > xi_strUserComment = "test user"
> > p_lngFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT Or UF_DONT_EXPIRE_PASSWD
> > WriteLog "staging in AD user..."
> > ' ------------------------------------------
> >     ' Create byte arrays to avoid Unicode hassles
> >     ' ------------------------------------------
> >     p_abytServerName = xi_strServerName & vbNullChar
> >     p_abytUserName = xi_strUserName & vbNullChar
> >     p_abytUserFullName = xi_strUserFullName & vbNullChar
> >     p_abytPassword = xi_strPassword & vbNullChar
> >     p_abytUserComment = xi_strUserComment & vbNullChar
> >     ' ------------------------------------------
> >     ' Get pointers to the byte arrays
> >     ' ------------------------------------------
> >     p_lngPtrUserName = VarPtr(p_abytUserName(0))
> >     p_lngPtrUserFullName = VarPtr(p_abytUserFullName(0))
> >     p_lngPtrPassword = VarPtr(p_abytPassword(0))
> >     p_lngPtrUserComment = VarPtr(p_abytUserComment(0))
> > With p_typUserInfo3
> >       .usri3_acct_expires = TIMEQ_FOREVER ' Never expires
> >       .usri3_comment = p_lngPtrUserComment ' Comment
> >       .usri3_flags = p_lngFlags ' There are a number of variations
> >       .usri3_full_name = p_lngPtrUserFullName ' User's full name
> >       .usri3_max_storage = USER_MAXSTORAGE_UNLIMITED ' Can use any
> > amount of disk space
> >       .usri3_name = p_lngPtrUserName ' Name of user account
> >       .usri3_password = p_lngPtrPassword ' Password for user account
> >       .usri3_primary_group_id = DOMAIN_GROUP_RID_USERS ' You MUST
> > use this constant for NetUserAdd
> >       .usri3_script_path = 0&       ' Path of user's logon script
> >       .usri3_auth_flags = 0&        ' Ignored by NetUserAdd
> >       .usri3_bad_pw_count = 0&      ' Ignored by NetUserAdd
> >       .usri3_code_page = 0&         ' Code page for user's language
> >       .usri3_country_code = 0&      ' Country code for user's
> >       language .usri3_home_dir = 0&          ' Can specify path of
> > home directory of this
> >       'user
> >       .usri3_home_dir_drive = 0&    ' Drive letter assign to user's
> >       'profile
> >       .usri3_last_logoff = 0&       ' Not needed when adding a user
> >       .usri3_last_logon = 0&        ' Ignored by NetUserAdd
> >       .usri3_logon_hours = 0&       ' Null means no restrictions
> >       .usri3_logon_server = 0&      ' Null means logon to domain
> >       server .usri3_num_logons = 0&        ' Ignored by NetUserAdd
> >       .usri3_parms = 0&             ' Used by specific applications
> >       .usri3_password_age = 0&      ' Ignored by NetUserAdd
> >       .usri3_password_expired = 0&  ' None-zero means user must
> > change password at next logon
> >       .usri3_priv = 0&              ' Ignored by NetUserAdd
> >       .usri3_profile = 0&           ' Path to a user's profile
> >       .usri3_units_per_week = 0&    ' Ignored by NetUserAdd
> >       .usri3_user_id = 0&           ' Ignored by NetUserAdd
> >       .usri3_usr_comment = 0&       ' User comment
> >       .usri3_workstations = 0&      ' Workstations a user can log
> > onto (null = all stations)
> >     End With
> >     WriteLog "creating AD user from NetUserAdd..."
> >     Dim objComputer
> >     Dim strComputer As String
> >
> >     p_lngRtn = NetUserAdd(p_abytServerName(0), _
> >     3, p_typUserInfo3, p_lngParamErr)
> >
> > 'code ends
> >
> > "Jim Mack" wrote:
> >
> >> Dipesh_Sharma wrote:
> >>> Hi,
> >>> I want to create an application which on passing a user id &
> >>> password will create that user on windows 2003 AD server. I used
> >>> netuseradd API to do this, but was not able to create user on AD
> >>> server & boot my system with that user. CAn anybody please help me
> >>> do this. if i am doing right what could be the problem. i am
> >>> getting unknown user type error. i found few scripts but they need
> >>> to be run on server itself not on remote system in network.
> >>
> >> Perhaps you could post the VB6 code you're using now, and we can
> >> spot a problem...
> >>
> >> --
> >>    Jim Mack
> >>    Twisted tees at http://www.cafepress.com/2050inc
> >>    "We sew confusion"
> >>
> >> .
> 
> .
> 
0
Utf
8/6/2010 11:32:03 AM
Reply:

Similar Artilces:

Managed User #2
Testing to see if this setup allows me to be properly identified as a managed user. ...

"grouping" a table to prevent change from users
Hi, I would like to group an entire table with a wdContentControlGroup type of Content Control to prevent editing from users except in some wdContentControlRichText type of Content Control. I'm having problem in passing the right Range of the table. If I use: With ActiveDocument Set r = .Tables(1).Range Set objcc = .ContentControls.Add(wdContentControlGroup, r) End With an error "5224" "Wrong selection" arise. If I use: With ActiveDocument .Tables(1).Select Set objcc = .ContentControls.Add(wdCo...

create progressive graph for slide show
Hello, I am fairly good at the basic in excel but I can't work out a quick way of doing this: I have a large table of data about 50 by 8000 and am using it to plot graphs. The problem is I want to create a slideshow to show at a seminar which will start off using just the first row of data and then progressively add more rows and display each line graph one at a time. I can't see any simpler way of doing this except to copy and paste each graph into PowerPoint on a time which would take for ever! Ideally I would like the scale to update automatically but that�s not too important. ...

Adding stages to a Sales Process
Hi, I want to add two new stages to a current sales process. Has anyone done this before? Any issues arise with previous opportunties, reporting, etc? Thanks, Sinead. -- Sinead O''''Shaughnessy previous opportunities will not see the new stages ============================== John O'Donnell Microsoft CRM MVP http://www.crowecrm.com "Sinead" <Sinead@discussions.microsoft.com> wrote in message news:8EC75D1E-06C5-4A6E-813D-1B5816DE87B6@microsoft.com... > Hi, > I want to add two new stages to a current sales process. Has anyone done > this bef...

Outlook 2003 incoming mail server
I posted a message this morning asking for help. Harvey Yancey [MSFT] responded, but then I replied and never heard from anyone again. I tried emailing Mr Yancey, but the address harveyy@online.microsoft.com is no good. Please, someone, read this and help me! The initial message is on the bottom. >-----Original Message----- >Hi Tanya, > >What is the complete error message that you are receiving? > >Regards, > >Harvey Yancey [MSFT] >Exchange Client/Server Infrastructure >harveyy@online.microsoft.com > >This posting is provided "AS IS" wi...

CPU spikes on sql server
We have noticed most of the same performance issues that are reported around here, but in trying to research a few of these I noticed the following strange behavior. Every 10 minutes a sql agent runs a process for "stored procedure priming". When this runs, the cpu on the server pegs at 100% for about 30 seconds. then back to 0% or so until the next firing This is a almost brand new install and only 1 or 2 users hit it. We have only begun to put data into it, so there isn't very much. Seems odd to me that a frequently scheduled process would hit things that hard that ...

Server-Requested Client Action error: MoveCopy unable to create dest msg
I have a user receiving this error message. Server-Requested Client Action error: MoveCopy unable=20 to create dest msg Outlook 2002. Theare are no rules configured.=20 Any Idea? tks, Alisson S. Ara=FAjo ...

Adding and subtracting from a column.
I have a stock list with a "quantity" column. What I would like to do is add the new stock to the existing quantity column or subtract requisitioned items from the quantity column. I guess it is a "self totaling" column I need to make. As a separate exercise I would like to make a new column for orders. Insert a quantity on that column for any of the items ( rows) I want to order and then print it out... BUT I only want to print the rows that have quantities in that column ( i.e. the actual items I am ordering ). This column is not linked to the above column. Could an...

Adding items (hours) into invoices
Hello, In my M07 Home and Business, I get an error while entering an invoice as soon as I add hours and press enter. The program says that there's an error: "This operation can not be performed" When I select more help, I get a help page that say:Details Id: obres:34 Bron: 16.0 When I search on this I see that it is an error that's related to homepage settings, but that does not work for me. Any suggestions? Thanks, Eric ...

backup ISP with one exchange server
we have one exchange 2003 server and we use a External ISP T1 connection and the ISP DNS which has the MX record. 10 email.domain.org (First ISP IP address for the email server) 20 email2.domain.org (second ISP IP address for the email server) We have a backup ISP connection that stays idle. when we switch over to the backup ISP connection (because the first is down) we cannot get the incoming email in. Outgoing works fine. How can we get the incoming email to route to the one exchange server with either ISP? On 18 Jan 2007 18:06:16 -0800, "zakmanx" <lskw360@sbcglobal.net&g...

URGENT: Creating a chart (Getting the correct input and output) unable to figure out
Hi, I have been trying to create this chart since a long time now and go no clue what am donig wrong. I have some machines in my company and all of them have a end of life for example: Machine 1, at location A with End of Life in 2004 Machine 2, at location B with End of Life in 2008 I want the years on x-axis and the machine locations on y-axis. Afte that I want horizantal lines representing machines which also show th end of life. For a better understanding, see the attached excel file. I have als created an image of the chart I'm looking to draw. Please advise. Thanks. Ker ...

Exchange Front End Server Question
We currently are running SBS 2003 and Enterprise Exchange. Our SBS box is acting as our front end server. We are moving away from SBS and I will be moving exchange to it own server. Any ideas the amount of power a front end server will require? I would think that since it is only handling http requests, the box does not need to be that powerful We have about 35 users with expected growth over the next 3 years to 80 users. Thanks, Mike 3 years? Who knows, in 3 years you might get a 64bit 16GB RAM 12GHz processor machine for $19.95 to run Exchange <insert new marketing name&...

Re-enabling a disabled user problem
Hello, On my Exchange server (SBS 2003, Exchange 2003), I was recently instructed to delete a couple of logins of people who left the company. I like to simply disable them for a while just in case we need to get back into their mailboxes. One one such user, it turns out he still needs to use his mailbox. I re-enabled him, but all subsequent emails are bounced back ("The message reached the recipient's e-mail system, but delivery was refused. Attempt to resend the message. If it still fails, contact your system administrator."). How do I open up the mailbox to receive emai...

How to create a Sub validation list in excel?
How can i make a validation list that is dependant on a value in a cell from another validation list, for eg I choose the make of a car from a list then the list next to that changes to the models of that particular make of car, is this possible and if so please could you enlighten me See http://www.contextures.com/xlDataVal02.html -- Regards Ron de Bruin http://www.rondebruin.nl "Simon" <Simon@discussions.microsoft.com> wrote in message news:0BC9D8ED-243C-4376-9C9D-4F1F65AFACBD@microsoft.com... > How can i make a validation list that is dependant on a value in a ce...

Activate Mailbox Calendars without logging on as user?
Hi Exchange experts, I have created a test site with an OU of 20 users with Exchange 2003 mailboxes. I would like to use PFDAVAdmin to grant everyone read only permissions to the calendars and grant publishing editor (or equivalent) permissions on the calendars so I can populate the users with test appointments. I understood that PFDAVAdmin synchronizes free/busy info at the same time as it assigns permissions. However, I am having two problems that I would appreciate you advice on : a) I cannot seem to access the mailbox calendar properties in PFDAVAdmin until I try to access them ...

How do I create a poster consisting of 4 x A4 pages which get glue
I know this can be done as I have done it some yaers before. It may have been in Power Point however. As I remember I created the poster content on the word document page and then using some option/s one is able to segment the page into 4 quarters, print these and then glue them together. I am using Microsoft Office Student and Teacher 2003 Word cannot create posters - try Publisher. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP...

howto only create a .lib file instead of creating/linking a complete dll
hi all, i have a librariy around here that gets compiled and linked to a dll. at the time of linking, visual studio 6 also creates a .lib file. how can i split that compiling/linking ? what i want to achieve is just only to generate this .lib file (because at that time i cant completly link my libs because of its dependencies) i already tried to export the dsp to a makefile and run: nmake -d mylib.dsp /MAKE "mylib - Win32 release but it seems that this also wants to create a .lib and a .dll file at the same time so i tried to run: nmake -d mylib.dsp /MAKE mylib.lib "mylib - Win3...

How do I save a worsheet from Excel 2002, for a user with Excel 2.
I know to use save as, I just don't know which one to save as. Hi excel 2000 will read version 2002 or 2003 files without any problems, so just a normal save should do it. BTW your question got trucated in the subject line, so it's a good idea to repeat the full question in the message body. Hope this helps Cheers JulieD "vkirkman" <vkirkman@discussions.microsoft.com> wrote in message news:99074D3E-1F9D-4B17-A474-FE22A5E6C81C@microsoft.com... >I know to use save as, I just don't know which one to save as. ...

Create Global Rule to re-direct tagged email?
Is it possible to create a global rule, which re-direct tagged email to another folder within each Outlook clients mailbox? We are using Exchange 2000 within a Windows 2000 and 2003 AD environment. We like to re-direct email, which is tagged as spam by our spam filter to another folder, which not yet has been created either. In stead of having to touch each client manually, we are looking for a global rule, which can manage this. Appreciate any help on this. Make sure all your clients are Outlook 2003 and then make sure your Spam filter integrates with Outlook so that they can redir...

Upgrading 2003 SBS to 2008R2 server Migrate?
I currently am running 2003SBS and want to migrate all users to a 2008R2 Enterprise server. I am running exchange. I read somewhere, these are built in tools? How would I migrate all AD users and exchange mailboxes to the server? I've used the swing method in the past from going to 2000 to 2003. Should I do the same or is there now built in tools making it easier? -- sentinelace Hello sentinelace, I suggest to use one of the SBS newsgroups/forums, there you will find the SBS experts: http://www.sbs2008.com/ Best regards Meinolf Weber Disclaimer: This posting ...

Restricting users to Send e-mail
Hi, I would like to restrict few of my user in sending e-mail within the same domain to a bunch of internal users. I have 2 users who shouldn't be able to send any e-mail to 150 internal users. Do we have any better method to do it? I already came across a method of denying the sender in each user but that's very cumbersome. Also 2 user is my internal user and I can't use SMTP connector to restrict them. Any ideas? Do these folks still need to be able to email to the outside world and/or other internal users? If not, then remove their permissions to access Exchange res...

SBS 2003 Internet Access for Users
I have a customer who has SBS 2003 Standard, 10 users with XP Workstations, and is connected to the internet via a Linksys ADSL router... He has asked me if there is any way that we could setup some form of "timed" internet access for his users... For example, he would like them to be able to use the internet between 12:00 and 13:00, but then it to be blocked... I know there are options with ISA but we don't have that, so what I'm after is a third party bit of software that may fit the bill... Does anyone know of such a beast? Regards Colin Hi Col...

Exchange Admin can't open Other Users Folder
Help, I am the Exchange admin for a small company with one Exchange 2000 server (AD). I am trying to open users folders much like I used to with Exchange 5.5 as the System Attendant. I am currently a member of everya dmin and exchange admin group available. And if I'm not, I can make myself a member of any group if I have to. Any suggestion is appreciated. Thank you -G gaguilar@caresclinic.org What do you mean under "users folders"? By default, administrators have Deny access permission set to Full mailbox access right. Hence they cannot see users mailboxes. Regards, Boris...

creating autofill fields
So I need to create an automatically generated record in a table when the previous fields time goes into the next day. For example. If a employee input his time as 9Pm-2am on 1/1/08, I need to automatically generate a record that has the time from 00-2am with the next days date:1/2/08 I also have to cap each days time at 12 midnight. I am not sure where to start with this entire sequence, can someone give me some guidance? Thanks. Christie You've described "what", but not "why". You've described "how", but not explained what having this kind...

Adding minutes to Now() problem...
Hi, I currently have a problem regarding adding times. Situation is this, I have a column with numbers representing minutes, and another column that I want to display the current date and time PLUS those minutes. eg If todays date and time is 13/07/2004 13:52, and I have 3000 in my minutes column, then i want my target cell to read 15/07/2004 15:52 However I'm using =NOW()+TIME(0,F4,0) and this is giving me 13/07/2004 15:52. So it's ignoring the days.... Is it something to do with formatting or is my formula the wrong one for what I am trying to achieve??? Many thanks in advance!...