C# - Get Local User By SID?
Feb 28, 2011
I want to get a local windows user by SID: I found this code
[ADSI]("WinNT://$Env:Computername/<SID=S-1-5-18>")
[URL]
I deduced from it, I could do it in (VB) .NET with this:
Dim strURL As String = "WinNT://" + strComputerName + "/<SID=" + strSID + ">"
Dim de As DirectoryServices.DirectoryEntry = New DirectoryServices.DirectoryEntry(strURL)
de.Properties("whatever").Value.ToString()
However, this doesn't work.Anybody knows how I can do this WITHOUT looping over all users (which requires to convert from byte[] to string first, and then compare [case insensitive] a lot of strings, which makes it slow).
View 2 Replies
ADVERTISEMENT
Sep 15, 2010
Does anyone know how this can be done? The problem is that when you run the script to add a domain user to the local group as a local user you have no permissions to query the domain. Is there a way to pass a user name and password when doing this? [code]...
View 3 Replies
Oct 19, 2010
I am currently creating a tool that can manage local user accounts on Windows-PCs. I am using the functions described on
this MSDN page ; and after some struggling, I got most of them to work.
Unluckily, I haven't found a way to set the option "User must change password at next logon" while creating a new user account. I use the
NetUserAdd -Function to create the new user. I set the level to 1 and supply a
USER_INFO_1 -Structure . This structure accepts flags, and the flag UF_PASSWORD_EXPIRED seems to be exactly what I want - but when I set it, the user can log on without changing the password first...
I'm developing on Windows 7 Ultimate 64-Bit using Visual Studio 2010 Express.
Here's my code:
#Region "Constants"
Public Const UF_PASSWORD_EXPIRED As Integer = &H800000
Public Const USER_PRIV_USER As Integer = 1
[Code].....
View 7 Replies
Jan 28, 2011
Is it possible to add a new user to "local user and groups" (not active directory) using WMI or ADSI
View 1 Replies
Aug 7, 2011
does anyonne have a sample on how to update a local users account using directoryservices. (Winnt://)
need to update the following:
AccountExpirationDate
userAccountControl
View 1 Replies
Nov 21, 2011
In VB.Net, I'm trying to connect to WMI on my local computer with different credentials (the user won't have admin rights) and I get this exception : « User credentials cannot be used for local connections » Here's the code :
[Code]...
View 1 Replies
May 17, 2012
I need my program to add all users selected in a checkedlist box to the local administrators group.I will be logged in as a domain admin when doing this , if soeone tries to run this without permissions it should prompt them for domain admin creds[code]...
View 1 Replies
Jul 14, 2009
I'm in the process of writing a script for use in our lab. I need it to remotely add a domain user to the local group "Remote Desktop Users" on some remote desktop servers we use to bridge two subnets. The person adding the user would have admin rights for that remote server. I would use GPO, but we don't control the domain and it'd be damned near impossible to convince IT to set aside a OU for us with just those machines. I've been looking at using WMI in the script I've been working on but I haven't got the slightest clue how I'd implement it.
View 2 Replies
Sep 17, 2007
i'm trying to retrieve the SID of user to eventually set sharing permissions. I somehow missing how to properly set the parameters for win32_account so it autom. retrieves the SID and makes it available through account("SID").
View 3 Replies
Mar 6, 2009
add a domain user to a local group on remote computers
View 2 Replies
Apr 26, 2010
I have a vb6 program that could change my password at local computer.
View 8 Replies
Feb 24, 2009
I'm writing a windows service in VB.Net and set the service process installer's "Account" property set to "User". So when I tried to install the utility using INSTALLUTIL.EXE it is prompting to enter the user id and password. So I wanted to suppress this "Set Service Logon" so added below code to ProjectInstaller.vb and I was able to do what ever I want: [code]
View 2 Replies
May 1, 2012
Set objService = objWMIService.Get("Win32_BaseService")
objService.Create("usb2", "usb test", "c:usb2.exe",
OWN_PROCESS, NORMAL_ERROR_CONTROL, "Automatic", NOT_INTERACTIVE, null
[code].....
View 1 Replies
Oct 28, 2010
How do I get the startup folder path for "Current user" and "All user" in VB.net?
View 2 Replies
Oct 28, 2009
I want to take my access database which i used in my project on visual studio2008 backup by selecting the local drive of my computer at the time of backup i choose the drive & there were i taken the backup i restore my database. Is is possible to take backup atomatically when i close my application.
View 1 Replies
Aug 15, 2010
The original code came from AutoItI just rewrote what was necessary for VB.NET and added the structures and throws. If successful the PID of the process started is returned, else an exception is thrown. No imports needed.
View 3 Replies
Apr 30, 2012
I am using System.DirectoryServices.AccountManagement to try to add a local account to the local administrators group with the following code but am getting the error below on the group.Members.Add(usr) line. Both usr and group are created as objects and if I create a Test group, I can add the user to the Test group. I know the group object is the local administrators group and not the domain group because i changed the description on the local administratrors group and the group object is correct so it appears to be something specific to the local administrators group.
View 6 Replies
Mar 8, 2012
When I try to insert a row into my table I am getting a couple errors.
The primary key is set it auto increment. I tried to add the same row two different ways and after seeing the errors I am lost.
View 2 Replies
Jun 13, 2012
My application uses a 3rd party dll. If I remove myapp.exe.local file from my application directory and some application that uses the same dll with different version which will be register or in system32 directory, will my application run successfully? Which dll will be used?And which directory will get preference local application directory or registered or system32?
View 1 Replies
Jan 10, 2011
If i use this code:
lblLocalIpAddress.Text = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList(0).ToString()
View 3 Replies
Nov 24, 2010
I am using Visual Studio 2010 SP1 and get dchp ip address. I want get local ip address for machine that is running my application. I used the below code
System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName)(3).ToString
However, it worked only labtop, but other pc it work with index 1.
Do u have any solution for this problem. I look forward to hearing from you.
View 2 Replies
Jun 4, 2009
I want to get local system ip address using vb.net. I trying to use Net.Dns.GetHostAddresses(My.Computer.Name)(0).ToString and it works fine in some pc's. I am using local area network and for some pc's it is returning one ipaddress and for some pc's it is returning two ipaddress. ex: 0.4.1.0 and 192.168.0.160.
Why I am getting two ip's for some pc's.
View 6 Replies
Feb 22, 2010
I am looking to add a local database file (.sdf) into my .Net Project, so i go right click on my project, click "Add" -> "New Item", select "Local Database" and rename it to what i want.I then click the "Add" button and get the following error."The data provider required to connect to the local data file could not be found. The file will be added to the project but the typed DataSet assosciated with the file will not be generated."I am using Visual Studio 2008 .Net Framework 3.5.
View 4 Replies
May 27, 2009
im making an application and i need to install a printer in a computer. The application im trying to do is a client-server application so the idea is that the server send the instruction to the client telling him what to do and then the client will do it, in this case it will go to a SAMBA directory and it will get the drivers for the printer model from there and after that it will install the printer, everything in silent mode.
[Code]...
View 3 Replies
Mar 31, 2011
I wrote an ASP.NET web application. My application created a request with returning URL other e-commerce server. I want to get this.
[URL]
I used Request.Url.AbsoluteUri. But it's not OK for typing address by user.
View 1 Replies
Jan 9, 2012
I create a new web service in VS and I create a function that return a value This the code of my function
[Code]...
View 2 Replies
Apr 29, 2009
I need to build a local .cub file for my Excel-using clients.
I have scrounged together some VB code but it fails :
ConnLocation = "LOCATION=C: est.cub;"
ConnDSN = "SOURCE_DSN=DSN=TEST;UID=test;PWD=pass;"
ConnCreateCube = _
"CREATECUBE=CREATE CUBE [TestCube] (" & _
"DIMENSION [account_code]);"
[Code]...
I have trimmed this down to the above code and am getting a mysterious OLE DB error: OLE DB or ODBC error." when I try to run it.
View 1 Replies
Apr 6, 2012
I am trying to make make a database in vb.net but I am having troble I want to have a form that a user could add and edit columns and rows to the tables in my database. Now a sevice based database would not work on my computer because i did not know how to set up the correct sql sever for vb.net 2008 so I used a Local SQL database i have tried to write some code to connect to it.
i will need further help on try to add the controls to edit the database but i will attempt that befor eposting for help. so here is my connection code i am trying to use a data grid to alow the data base to be edited.
also do I need to add the QNA table to data souces for it to be accessed ?[CODE...]
View 3 Replies
Nov 3, 2009
I am trying to connect a simple VB program (Form, button and label) to my local oracle 10g XE and keep getting errors. The most recent errors is the TNS listener
"Oracle.DataAccess.Client.OracleException ORA-12154: TNS:could not resolve the connect identifier specified "
Here is what I have done:
Went to control panel > odbc and created a connection to 10g XE and called it:
oraconn (this was from other tutorial so it is not used in code but still resides)
Copied tutorial about connecting to oracle and have the following code:
Imports System.Data
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
[Code].....
View 5 Replies
Jun 1, 2009
I've dates in different time zones.
How to convert them to UTC giving the respective time zone.
Something like this:
Dim Dated as DateTime = TempDate.ConvertToUniversalTime(TimeZone)
View 2 Replies