<div class="body"> <div>I have to add a user in security tab(with read and write permission) for a selected GROUP using c# code. Please help me how to add the person in security tab using code.</div> </div>
I donot want to add roles. I have to give user additional rights to manage Group in AD. I found the code for that, but dont know what name to add for "User_Name". Is it the dintinguished name or logon name.
DirectoryEntry directoryEntry =
newDirectoryEntry("LDAP://path for
Group");
i'm getting access denied while using the above code.
In UI i can add user and assign the permissions to that user. But using same credentials if i try the above code then its throwing error : ACCESS IS DENIED.
nix_16
0 Points
3 Posts
Give permission to another user on a Group using ActiveDirectorySecurity
Dec 06, 2012 05:00 AM|LINK
Hi guys,
<div class="body"> <div>I have to add a user in security tab(with read and write permission) for a selected GROUP using c# code. Please help me how to add the person in security tab using code.</div> </div>Silverlight....
Member
431 Points
373 Posts
Re: Give permission to another user on a Group using ActiveDirectorySecurity
Dec 06, 2012 05:04 AM|LINK
first use : using System.Security namespace
second : write : Roles.AddUserToRole("YOURUSERNAME","YOURROLE")
Try it !!!
nix_16
0 Points
3 Posts
Re: Give permission to another user on a Group using ActiveDirectorySecurity
Dec 06, 2012 06:00 AM|LINK
Hi ,
I donot want to add roles. I have to give user additional rights to manage Group in AD. I found the code for that, but dont know what name to add for "User_Name". Is it the dintinguished name or logon name.
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://path for Group");
ActiveDirectorySecurity adSecurity = directoryEntry.ObjectSecurity;
string sd = adSecurity.GetSecurityDescriptorSddlForm(AccessControlSections.All);
IdentityReference newidentity = new System.Security.Principal.NTAccount("User_Name");
ActiveDirectoryAccessRule newAccessRule = new ActiveDirectoryAccessRule(newidentity, ActiveDirectoryRights.WriteOwner, AccessControlType.Allow);
directoryEntry.ObjectSecurity.AddAccessRule(newAccessRule);
directoryEntry.CommitChanges();
nix_16
0 Points
3 Posts
Re: Give permission to another user on a Group using ActiveDirectorySecurity
Dec 06, 2012 10:47 AM|LINK
i'm getting access denied while using the above code.
In UI i can add user and assign the permissions to that user. But using same credentials if i try the above code then its throwing error : ACCESS IS DENIED.
Can anybody help me with that. :(
Angie xu - M...
All-Star
20277 Points
1726 Posts
Microsoft
Re: Give permission to another user on a Group using ActiveDirectorySecurity
Dec 12, 2012 07:48 AM|LINK
Hi nix
You could refer the case about assigning rights to the user group for particular OU in Active directory using C# below,
http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/1283a2d0-0c76-442c-af4b-db255bca3215
Moreover, it's necessary for you to learn the usage of AddAccessRule method in ActiveDirectorySecurity Class,
http://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectorysecurity.aspx
Kind regards
Feedback to us
Develop and promote your apps in Windows Store