From: Dipesh_Sharma on
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(a)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"
> >>
> >> .
>
> .
>
From: Dipesh_Sharma on
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(a)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)
> .
>
From: Dipesh_Sharma on
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(a)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"
> >>
> >> .
>
> .
>
First  |  Prev  | 
Pages: 1 2 3
Prev: Casting in VB6
Next: VB6 new install