We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,503 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Create User Account in vb.Net

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

4
Contributors
5
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
6
Views
manikandan22
Newbie Poster
2 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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
oUser.SetInfo()
oUser.SetPassword("Password")
oUser.SetInfo()
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

Doogledude123
Junior Poster in Training
90 posts since Jun 2012
Reputation Points: 0
Solved Threads: 7
Skill Endorsements: 0

Please specify more details....

poojavb
Posting Pro
524 posts since Nov 2011
Reputation Points: 39
Solved Threads: 77
Skill Endorsements: 5

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("FullName").Add(fullName)
    newUser.Properties("HomeDirectory").Add("C:\Sites\manjaly")
    newUser.Properties("Description").Add("Member of site.")

    ' User must change password at next logon (1 - true, 0 - false)
    newUser.Properties("PasswordExpired").Add(0)

    ' Password never expires.
    'newUser.Properties("PasswordAge").Add(0)

    ' 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)


    newUser.CommitChanges()

    ' 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.

manikandan22
Newbie Poster
2 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

sirasingh
Newbie Poster
5 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

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

Doogledude123
Junior Poster in Training
90 posts since Jun 2012
Reputation Points: 0
Solved Threads: 7
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0645 seconds using 2.64MB