473,386 Members | 1,694 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.

Add group to an computer object security tab AD

Hi,
When you create a computer account in Active Directory (manually), you can change "The following user or group can join this computer to a domain". When you do this, the user or group is added to the security tab.

I would like to do this with c# (automatically) and I cannot find a solution.

Thank you for your help
Sorry! I'm not an english people.
Attached Images
File Type: jpg AddPC.jpg (14.4 KB, 411 views)
Jul 12 '10 #1
1 3094
Hi,
I receive this error message : Object reference not set an instance of an object.

My code :

DirectoryEntry computers = new DirectoryEntry(sLDAP + PCTarget, "Domain" + "\\" + "user", "Password", AuthenticationTypes.Secure);
computers.Options.SecurityMasks = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl | SecurityMasks.Sacl;

try
{
ActiveDirectorySecurity sdc = computers.ObjectSecurity;
NTAccount Account = new NTAccount("Domain\\MyGroupName");
SecurityIdentifier Sid = (SecurityIdentifier)Account.Translate(typeof(Secur ityIdentifier));
ActiveDirectoryAccessRule rule = new ActiveDirectoryAccessRule(Sid,ActiveDirectoryRight s.ExtendedRight | ActiveDirectoryRights.GenericRead,AccessControlTyp e.Allow);
The message appears when the SetAccesRule is executed!!!
sdc.SetAccessRule(rule);
computers.CommitChanges();
computers.Close();
computers.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}

Thank you
Jul 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Angela | last post by:
This question is in reference to another question I posted titled, "This advertised application will not be installed because it might be unsafe". The error I am getting says I need to change...
3
by: Noloader | last post by:
Hello, We are using Access Front End (ADP Project) and SQL Server 2000 backend. SQL Server is using NT Security. We do not want the users to access the the underlying tables. So, we went to...
1
by: Bishop | last post by:
I see the LastLogin property exists: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adschema/adschema/a_lastlogon.asp but when I query it, it always returns null. Anyone know...
0
by: Bob Darlington | last post by:
I am using A2002. In the User and Group Permissions dialog, the 'Object Name' list box appears to be listing forms which have recently been imported (from backup copies of the program) in an order...
1
by: Rodolfo | last post by:
Can I make that an object to destroy himself? I want to put some code in the constructor of a class (call to my security service). If it doesn't have the permissions I want to not let the object...
0
by: Jay Armstrong | last post by:
I am creating computer accounts from a web interface and need to set the group that has the rights to join the computer to the domain (by default it is Domain Admins). I can create the accounts,...
0
by: widmerd | last post by:
Would anyone have the code to replace the name in the "managed by field" of a computer object with another name. Thanks
13
by: birchw | last post by:
Hi, having never used the security features under the tools menu in Access 2000, I thought I'd experiment with them on a copy of my database. Or so I thought! Everything was going well - I...
0
by: ncstang | last post by:
I am writing a script to create folders within a FileShare. I have almost all of it workign except for the Group Access portion. Becuase the folder inherits the FileShare's security upon creation, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.