|
-
Jan 14th, 2006, 03:39 AM
#1
Thread Starter
Addicted Member
How to create windows user using VB.NET
I have a table in sql server storing all staff in a company and I want to create user in windows for all staff. I don't want to create it one by one. Can i use vb.net to create theses users or is there any way? Please tell me step by step.
-
Jan 14th, 2006, 03:56 AM
#2
Re: How to create windows user using VB.NET
You will want to use Active Directory (AD) or Windows Management Instrumentation (WMI) to do it. You are trying to create local users or domain users, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 14th, 2006, 06:56 AM
#3
Re: How to create windows user using VB.NET
To create a user you'd use ADSI. WMI is for hardware related methods, isn't it?
VB Code:
Public Sub AddUser(ByVal strDomainName As String, ByVal strLoginName As String, ByVal strPwd As String)
Dim obDirEntry As DirectoryEntry = Nothing
Try
obDirEntry = New DirectoryEntry("WinNT://" + strDomainName)
Dim entries As DirectoryEntries = obDirEntry.Children
Dim obUser As DirectoryEntry = entries.Add(strLoginName, "User")
obUser.Properties("FullName").Add("MENDHAK THE FROG")
Dim obRet As Object = obUser.Invoke("SetPassword", strPwd)
obUser.CommitChanges
Catch ex As Exception
'Handle the Error
End Try
End Sub
-
Jan 14th, 2006, 08:14 AM
#4
Re: How to create windows user using VB.NET
WMI is not just for hardware.
The Win32_Account abstract WMI class contains information about user accounts and group accounts known to the Windows system. User or group names recognized by a Windows NT domain are descendants (or members) of this class. The Win32_Account class is not included in a default hardware inventory operation.
The Win32_UserAccount WMI class contains information about a user account on a Windows operating system.
Can you use ActiveDirectory on a stand alone machine?
-
Jan 14th, 2006, 09:25 AM
#5
Re: How to create windows user using VB.NET
Only if its got the ADSI type library or running Server w/AD.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 14th, 2006, 05:49 PM
#6
Re: How to create windows user using VB.NET
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 01:07 AM
#7
Addicted Member
Re: How to create windows user using VB.NET
 Originally Posted by mendhak
...
obDirEntry = New DirectoryEntry("WinNT://" + strDomainName)
Dim entries As DirectoryEntries = obDirEntry.Children
Dim obUser As DirectoryEntry = entries.Add(strLoginName, "User")
Imports What? I tried Microsoft.win32, etc, never work though!
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
-
Jan 17th, 2006, 01:28 AM
#8
Re: How to create windows user using VB.NET
 Originally Posted by Codehammer
Imports What? I tried Microsoft.win32, etc, never work though!
http://www.google.com/search?client=...utf-8&oe=utf-8
First link, form the MSDN says it's in the System.DirectoryServices namespace.
-
Jan 17th, 2006, 01:28 AM
#9
Re: How to create windows user using VB.NET
I went to the help/MSDN library and searched for "directoryentry class". The third result was for the System.DirectoryServices.DirectoryEntry class. The help really is helpful. The page that Rob linked to even has a link to that very topic and half the other links specifically mention the DirectoryServices namespace.
-
Jan 17th, 2006, 05:41 AM
#10
Re: How to create windows user using VB.NET
It's surprising how much a little, tiny search can answer if you just take the time out to do it. That was an extremely simple question, ya see?
-
Jan 18th, 2006, 12:32 AM
#11
Addicted Member
Re: How to create windows user using VB.NET
 Originally Posted by mendhak
It's surprising how much a little, tiny search can answer if you just take the time out to do it. That was an extremely simple question, ya see?
My Last Imports Question Ever Again!
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|