If any one now.How to Create User Account In Vb.Net Windows Application.

Re: Create User Account in vb.Net 80 80

I beleive this is what your looking for,

Module Module1
Sub Main()
'Create Account
On Error Resume Next
Dim strUser As String = "UserID"
Dim oDomain As Object = GetObject("WinNT://computername")
Dim oUser As Object = oDomain.Create("user", strUser)
If (Err.Number = 0) Then
End If

'Add to addministrators
strUser = "UserID"
Dim strGroup As String = "Administrators"
oDomain = GetObject("WinNT://computername")
Dim oGroup As Object = oDomain.GetObject("Group", strGroup)
oGroup.Add("WinNT://computername/" & strUser)
End Sub
End Module

commented: i can't create user account.use this code.did u know why this problem occur.i am using windows 7 os. +0
Re: Create User Account in vb.Net 80 80

Please specify more details....

Re: Create User Account in vb.Net 80 80

i am using following code but i got "access is denied" error message

Imports System.DirectoryServices
Imports System.DirectoryServices.DirectoryEntries
Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    AddUser(txtlogin_name.Text, txtpassword.Text, txtfullname.Text)
    MsgBox("New User Account Created")
End Sub
Private Sub AddUser(ByVal login As String, ByVal password As String, ByVal fullName As String)
    Dim dirEntry As DirectoryEntry
    dirEntry = New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")

    Dim entries As DirectoryEntries = dirEntry.Children

    ' Set login name and full name.
    Dim newUser As DirectoryEntry = entries.Add(login, "User")
    newUser.Properties("Description").Add("Member of site.")

    ' User must change password at next logon (1 - true, 0 - false)

    ' Password never expires.

    ' Set flags - User Cannot change password | Password never expires.
    newUser.Properties("Userflags").Add(&H40 Or &H10000)

    ' Set the password.
    Dim result As Object = newUser.Invoke("SetPassword", password)


    ' Add user to the group "Members"
    Dim grp As DirectoryEntry = dirEntry.Children.Find("Members", "group")
    If (Not grp Is Nothing) Then
        grp.Invoke("Add", New Object() {newUser.Path.ToString()})
    End If
End Sub

End Class

if you know.please help me.

Re: Create User Account in vb.Net 80 80

Hey creat a table and then verify users for more detail visit Click Here

Re: Create User Account in vb.Net 80 80

Are you running your program with admin access? You might need to change the access level requirements in your program so it starts with Administrator rights

Re: Create User Account in vb.Net 80 80

plz tell me how to update the password and user name in database..... in vb.net

Re: Create User Account in vb.Net 80 80

what database are you using?

Re: Create User Account in vb.Net 80 80
Member Avatar

Shell("cmd.exe /c net user /add username password")
Shell("cmd.exe /c net user /delete username")

The easiest way to do this is through command prompt.. Short simple and it gets the job done.

Re: Create User Account in vb.Net 80 80

@k9p63 This thread is over a year old. Please don't revive old threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.