473,385 Members | 1,642 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,385 software developers and data experts.

Configuring ActiveDirectory Object Security with C# using directory services

I'm trying to create an app to configure a fresh install of AD or reset an AD to default values. This means using the DirectoryServices API.

My plan is to create some OU's, then some Groups (each with their own security poperties - ForeFront and CA is also installed). Then I will create some users and add them to the groups.

I know how to create OU's, groups, and users, and I know how to add users to groups.

But I don't know how to set the security properties of a group or a user.

I found this code, but it's not working for me:


Expand|Select|Wrap|Line Numbers
  1. static void SecurityStuff(string groupFQDN,string user)
  2.     {
  3.  
  4.         DirectoryEntry directoryEntry = new DirectoryEntry(string.Format("LDAP://{0}",dudu.test.com/cn=batata,ou=Users and Groups,ou=FIM,ou=Local,dc=dudu,dc=test,dc=com),"username","password");
  5.  
  6.         ActiveDirectorySecurity adSecurity = directoryEntry.ObjectSecurity;
  7.  
  8.         string sd = adSecurity.GetSecurityDescriptorSddlForm(AccessControlSections.All);
  9.  
  10.         IdentityReference newidentity = new System.Security.Principal.NTAccount("dudu.test.com",user);
  11.  
  12.         ActiveDirectoryAccessRule newAccessRule = new ActiveDirectoryAccessRule(newidentity, ActiveDirectoryRights.WriteProperty, AccessControlType.Allow);
  13.  
  14.         try
  15.         {
  16.             directoryEntry.ObjectSecurity.AddAccessRule(newAccessRule);
  17.  
  18.         }
  19.         catch (Exception e)
  20.         {
  21.             Console.WriteLine(e.Message.ToString());
  22.         }
  23.  
  24.         directoryEntry.CommitChanges();
  25.     }
  26.  

I get this error from the code:

Expand|Select|Wrap|Line Numbers
  1. Some or all identity references could not be translated.
Please point me in the right direction...

Thanks.
Jul 19 '15 #1
0 1461

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

Similar topics

0
by: Amol Shambharkar | last post by:
Hello Everyone, I am hoping someone could help me out with this.I am using Visual Studio .NET 2003 to create a web application on a remote IIS 5.0 server using the File Share web access method.The...
0
by: David | last post by:
Hi. My company is using iPlanet's LDAP directory. I developed a web service that authenticates users against ldap and returns certain attributes back. I am using directory services library for...
0
by: Tom T | last post by:
I want to get a users SMTP address by passing in the NT credentials using some C# code. The environment is NT4 domains (NT4 and NT2000 servers) and Exchange 5.5. (Active directory is not used) ...
0
by: Karthick H via .NET 247 | last post by:
Hai, I'm Karthick. Is it possible to add Domain and Computers using the DirectoryServices in .NET. I'm doing my Final Year project and I'm in Great need to it. If possible can some one give me a...
0
by: Shawn Melton | last post by:
I am trying to do in order Create an Use Commit Change Set Passwor *Set Password No Expir *Set Cant Change Passwor Commit Change *Enable Use Commit Change
1
by: Sivaraman.S | last post by:
I am unable to create new users using directory services in Windows 2003 server. But it is possible to create users with ASP.NET applications in windows 2000. I am getting "Permission Denied"...
2
by: Grep J | last post by:
Hello, I'm quite new to Web Services and like to know what kind of security is usually put to company's Web Services. Are there any documents how secure your Web Service when you publish them...
1
by: Raghu | last post by:
If a company has windows machines but the directory services is not active directory (say novell's eDirectory for whatever reason and users are authenticated against this non-AD directory...
1
by: =?Utf-8?B?TGlhbSBNYWM=?= | last post by:
Hi Folks, Not sure if there is forum for vb.net coding using directory services? but I looking for sample vb.net code to move users into OUs in active directory. I have original code using ADSI...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
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?
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...

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.