473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Urgent: Adding users to log on locally list programmatically using C#

Does anyone know how to add users to the log on locally list in User
Rights Management inside Local Security settings.

Thanks

May 4 '07 #1
12 5312
Your question really has little to do with C# programming (that's the subject
of this group) but here goes:

open Local Security Settings from Administrative Tools, Computer Management
in Control Panel.

open the User Rights Assigment tree node.

Find the Log on Locally item in the Policy (right) window.

Double-click on this, and you can then add users or groups.

Next time, try to post to the relevant newsgroup. You're more likely to get
help.

--Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ab************@gmail.com" wrote:
Does anyone know how to add users to the log on locally list in User
Rights Management inside Local Security settings.

Thanks

May 4 '07 #2
My apologies, you did say "programmatically". need to find the appropriate
WMI class to do this. For that, I can't help.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ab************@gmail.com" wrote:
Does anyone know how to add users to the log on locally list in User
Rights Management inside Local Security settings.

Thanks

May 4 '07 #3
<ab************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Does anyone know how to add users to the log on locally list in User
Rights Management inside Local Security settings.

Thanks

All members of the "users", "administrators" and "guest" groups are
automatically allowed to log on locally. What other users were you thinking
off?

Willy.
May 4 '07 #4
well. I am required to create a function that automates the following

start -settings -control panel -administrative tools -local
security policy -user assignment rights -find 'log on
locally' (open up properties) -add users or workgroups to that list.

hope that makes my question clear.

thanks

May 7 '07 #5
Oh and I had test users in mind, so basically - "testuser1" for
example.
May 7 '07 #6
<ab************@gmail.comwrote in message
news:11********************@n59g2000hsh.googlegrou ps.com...
Oh and I had test users in mind, so basically - "testuser1" for
example.


Well, actually there is nothing in the Framework that helps you with this.
So you will have to call into some WIn32 LSA API's using PInvoke.
Basically what you need to do is:
1. Get a LSA Policy handle for the target system, by calling LsaOpenPolicy.
2. Get the SID of the user account, by calling LsaLookupNames2
3. Add the "SeInteractiveLogonRight" for the account, by means of a call to
LsaAddAccountRights.
Note that LSA_UNICODE_STRING type as used in these API's is not a CLR
string, it's a structure you need to initialize correctly before you call
the API's, watch out!.

But again, before you can grant this privilege to an account, the account
MUST exist, why not simply create the account and make it a member of the
"users" group or a group which already has the "Allow Logon Locally"
privilege"?

Willy.
May 8 '07 #7
Thanks for the response Willy.

My initial plan was to add the user to a workgroup that was pre-
existing in the list, but then those workgroups might have privleges
which I would not want the users I create to have.
May 8 '07 #8
<ab************@gmail.comwrote in message
news:11********************@o5g2000hsb.googlegroup s.com...
Thanks for the response Willy.

My initial plan was to add the user to a workgroup that was pre-
existing in the list, but then those workgroups might have privleges
which I would not want the users I create to have.

But you are talking about local accounts, I don't think you have tens of
these on a local machine don't you?
If you are running in a Windows domain, you can achieve what you want by
applying Group Policy Management.

Willy.

May 8 '07 #9
On May 8, 6:29 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<abhishek.gi...@gmail.comwrote in message

news:11********************@n59g2000hsh.googlegrou ps.com...
Oh and I had testusersin mind, so basically - "testuser1" for
example.

Well, actually there is nothing in the Framework that helps you with this.
So you will have to call into some WIn32 LSA API's using PInvoke.
Basically what you need to do is:
1. Get a LSA Policy handle for the target system, by calling LsaOpenPolicy.
2. Get the SID of the user account, by calling LsaLookupNames2
3. Add the "SeInteractiveLogonRight" for the account, by means of a call to
LsaAddAccountRights.
Note that LSA_UNICODE_STRING type as used in these API's is not a CLR
string, it's a structure you need to initialize correctly before you call
the API's, watch out!.

But again, before you can grant this privilege to an account, the account
MUST exist, why not simply create the account and make it a member of the
"users" group or a group which already has the "Allow Logon Locally"
privilege"?

Willy.

I did that and it says -- "specified privilege does not exist" for
"SeInteractiveLogonRight"

May 8 '07 #10
<ab************@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On May 8, 6:29 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
><abhishek.gi...@gmail.comwrote in message

news:11********************@n59g2000hsh.googlegro ups.com...
Oh and I had testusersin mind, so basically - "testuser1" for
example.

Well, actually there is nothing in the Framework that helps you with
this.
So you will have to call into some WIn32 LSA API's using PInvoke.
Basically what you need to do is:
1. Get a LSA Policy handle for the target system, by calling
LsaOpenPolicy.
2. Get the SID of the user account, by calling LsaLookupNames2
3. Add the "SeInteractiveLogonRight" for the account, by means of a call
to
LsaAddAccountRights.
Note that LSA_UNICODE_STRING type as used in these API's is not a CLR
string, it's a structure you need to initialize correctly before you call
the API's, watch out!.

But again, before you can grant this privilege to an account, the account
MUST exist, why not simply create the account and make it a member of the
"users" group or a group which already has the "Allow Logon Locally"
privilege"?

Willy.


I did that and it says -- "specified privilege does not exist" for
"SeInteractiveLogonRight"

"SeInteractiveLogonRight" should exist, could you please post some code.

Willy.

May 8 '07 #11
On May 8, 3:29 pm, abhishek.gi...@gmail.com wrote:
On May 8, 6:29 am, "Willy Denoyette [MVP]"

<willy.denoye...@telenet.bewrote:
<abhishek.gi...@gmail.comwrote in message
news:11********************@n59g2000hsh.googlegrou ps.com...
Oh and I had testusersin mind, so basically - "testuser1" for
example.
Well, actually there is nothing in the Framework that helps you with this.
So you will have to call into some WIn32 LSA API's using PInvoke.
Basically what you need to do is:
1. Get a LSA Policy handle for the target system, by calling LsaOpenPolicy.
2. Get the SID of the user account, by calling LsaLookupNames2
3. Add the "SeInteractiveLogonRight" for the account, by means of a call to
LsaAddAccountRights.
Note that LSA_UNICODE_STRING type as used in these API's is not a CLR
string, it's a structure you need to initialize correctly before you call
the API's, watch out!.
But again, before you can grant this privilege to an account, the account
MUST exist, why not simply create the account and make it a member of the
"users" group or a group which already has the "Allow Logon Locally"
privilege"?
Willy.

I did that and it says -- "specified privilege does not exist" for
"SeInteractiveLogonRight"- Hide quoted text -

- Show quoted text -
whoops pressed the wrong button. Sorry about that

May 9 '07 #12
On May 9, 10:06 am, abhishek.gi...@gmail.com wrote:
On May 8, 3:29 pm, abhishek.gi...@gmail.com wrote:


On May 8, 6:29 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<abhishek.gi...@gmail.comwrote in message
>news:11********************@n59g2000hsh.googlegro ups.com...
Oh and I had testusersin mind, so basically - "testuser1" for
example.
Well, actually there is nothing in the Framework that helps you with this.
So you will have to call into some WIn32 LSA API's using PInvoke.
Basically what you need to do is:
1. Get a LSA Policy handle for the target system, by calling LsaOpenPolicy.
2. Get the SID of the user account, by calling LsaLookupNames2
3. Add the "SeInteractiveLogonRight" for the account, by means of a call to
LsaAddAccountRights.
Note that LSA_UNICODE_STRING type as used in these API's is not a CLR
string, it's a structure you need to initialize correctly before you call
the API's, watch out!.
But again, before you can grant this privilege to an account, the account
MUST exist, why not simply create the account and make it a member of the
"users" group or a group which already has the "Allow Logon Locally"
privilege"?
Willy.
I did that and it says -- "specified privilege does not exist" for
"SeInteractiveLogonRight"- Hide quoted text -
- Show quoted text -

whoops pressed the wrong button. Sorry about that- Hide quoted text -

- Show quoted text -
Thanks for all the help. Never mind replying to my previous message.
It was a really stupid mistake. Its all working.

Thanks again!

May 9 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan Trevor | last post by:
Hi, Spent nearly 8 hours googling and trying code on this yesterday without much success. I'd like to write a .NET application (using .NET primitives, older Win32 calls, or WMI etc) to work out...
4
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
by: enilno | last post by:
I'm working on a C# app., and I need to programmatically add a local user to a local group on the computer on which the app. is running. When end-users run this app., they will be logged on as...
3
by: Prash | last post by:
IIS serving javascript files, gives me error 4/21/2006 6:48 AM Guys/Gals, I am using IIS as a server to serve the javascript files. But it is giving me the error as "Object doesn't support this...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
3
by: jyothi.priya143 | last post by:
Hi Friends, Urgent Requirement for GENPACT is here for u now... Here u can upload a soft copy of ur resume in one click... Here U can also get Jobs-Freshers & Experienced, Sample Resumes,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.