add user to an organizational unit in active directory - sharepoint

I'm gonna build a webpart for creating user in active directory.
i want to add created user to an organizational unit if the organizational unit exist.
how i can do that?

Basically, you need to bind to the OU in question, and then call .Children.Add() to add the new user to that OU.
See this MSDN documentation for details:
Adding Directory Objects shows how to add a group to the Users container - you should be able to convert that to your needs
Quick List of C# Directory Services samples
User Management with Active Directory shows sample code for exactly what you're looking for: adding a user to an organizational unit
How to do almost anything in Active Directory using C# is a great general resource showing how to do common tasks in Active Directory using C# and .NET

Related

Azure Active Directory Object Permissions

I have an Azure Active Directory Application (and associated Service Principal). That Service Principal needs to be able to add and remove members from an Azure Active Directory Group...so I have added Read and write directory data under Application Permissions:
And I have code that uses the Client ID and Client Secret to get an Authentication Token an perform these operations using the Azure Graph API.
However, this permission is far too broad. I need the Application/Service Principal to only have the ability to add and remove members from specific groups (not all)...and not the ability to perform other types of operations.
Is there a way to do this?
Thank you.
There is a preview feature that partly fits your requirement: "Group.ReadWrite.All". It lets your principal create and update groups and their navigation properties (incl. members). It does not however reduce the permissions to modify only certain groups.
AAD permission scopes are described here: https://msdn.microsoft.com/Library/Azure/Ad/Graph/howto/azure-ad-graph-api-permission-scopes
Preview features may be subject to change and you'll have to agree to reduced service terms etc.: https://azure.microsoft.com/en-us/services/preview/

Automatically give permissions to user in Visual Studio Online

I have created visual studio online site using azure and backed by our company active directory.
And when going to user management site (example image, not my screenshot) in the search box I can see all the users from the active directory which means that I'm properly connected (I guess).
And here is the problem which I wasn't able to solve.
I would like to know if it is possible to automatically give read permissions to users from active directory that try to access the site.
Currently they can login, but when they access the site it says that they don't have permissions and I have to manually add them one by one and I don't want to do that.
Do I maybe need some special active directory group that I add there as a user or what? I'm not active directory admin so I don't have access to its settings.
Thank you for the help.
Currently VSO does not support AD groups. In addition, just because you assign a licence, does not mean that they should have permission to everything. You my be a special case, but the choice of access should be left to the Team Project owners.

SharePoint custom permission based on specific Organization Unit in the AD

Am pretty new to SharePoint, am working on creating a custom permission that I can deploy I sharepoint. I was hoping to create a custom permission that will read Organization Unit inside the active directory and if the user does not belong to a specific organization unit he will be prompted with access denied.
Is there a tutorial to do such a thing? or instructions as of where to start from?
follow the Below URL
Security Programming in SharePoint 2007

Security based on 2 Active Directory groups

Let's say I have 2 AD security groups: "Access to SharePoint" and "Access to Archive".
How do I set the security in this way on a SPWeb that only people who are member of both groups, are allowed access?
Is this possible with out of the box AD tools?
Thanks!
I am making the assumption that you are using SharePoint 2007. With that being said, its best practice to only apply security at the site collection level. Everything under the site collection level should inherit that security [e.g. sites, lists, libraries, items, documents].
EDIT:
*#OedipusPrime brought up a good point that I overlooked in my original answer. The best thing I can think of now to ensure a SharePoint group only allows users that are comprised of two different Active Directory groups would require a custom script that would need to be run on a regular basis (at least daily I would assume).
You'd still create a new Active Directory group, but you'd populate the group with a C# console application that would query Active Directory and determine which users were in both Active Directory groups ("Access to SharePoint" & "Access to Archive"), then programmaticlly assign those users into the new Active Directory group ("Restricted Site Access") and remove any users that were no longer in both groups. Not the best option, but the best I can think of for now if you're not able to manually control the Active Directory group access. This link provides some useful samples for C# / Active Directory interactions: http://www.codeproject.com/KB/system/everythingInAD.aspx*
After this new Active Directory group is created you can add the group to your SharePoint site and provide the permission level the group will have to the site.
Site Actions -> Site Settings -> Advanced Permissions -> New -> Add Users
Type in the Active Directory group you created
Select Give users permission directly
Choose the permission level
Uncheck the box to send an email
Click OK

Syncing profile details with active directory

Several fields in MOSS profiles are mapped to fields in active directory and we have given the user the ability to modify these.
But when the incremental profile import runs it overwrites these with the old values from active directory.
How do we make it so that AD is updated with the new values from the profile?
Thanks for any suggestions.
From http://blog.seancleaver.com/sean_cleaver/2008/07/sync-ad-users-to-sharepoint---2-way.html
So some of you have requested support to provide 2-Way Synchronization of AD Users between a SharePoint List and Active Directory. The good news is that the AD Provider for Data Synchronization Studio now supports this.
So you can effectively publish your AD Users to an Intranet Site to create a "Staff List" or "Telephone List" and then from this you can now allow your staff to update the personal information stored in the AD themselves by just simply editing the records in SharePoint. Then when the Synchronization occurs all changes are applied to the AD. There are a few limitations you can't create new AD Users this way and you can't delete users from the AD and certain properties are not updateable such as Member-Of etc.
We've given up on an easy way to do this and are writing a scheduled task that gets the recent change info from the users profile and updates AD from that.
Will try to post code once I've got something working.

Resources