Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Create AD user account from SharePoint

$
0
0

Hi,

I have created a webpart to create Active Directory Account. On button click i add following code but getting error

DirectoryEntry ouEntry = new DirectoryEntry("LDAP://OU=TestOU,DC=mydomain,DC=local");

When i add following line than got 
DirectoryEntry childEntry = ouEntry.Children.Add("CN=NewTestUser", "user");

error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below

i also tried following but getting error:

 PrincipalContext ouContex = new PrincipalContext(ContextType.Domain,"mydomain.com","OU=TestOU,DC=TDL,DC=local");
                UserPrincipal up = new UserPrincipal(ouContex);
                up.SamAccountName = "NewUser"; 

pls guide how to fix it 

thx


iffi


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>