http://groups.yahoo.com/group/ADSIANDDirectoryServices/
will answer this for oyu in minutes. Tons of MS employees and MVPs there.

On 11/28/05, Krishnan <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> I have to create a new user in active directory2000 and 2003. In AD 2003 I
> am not able to set Domain property (Please find attached screen shot)
> through code. Is there any way to set domain property? The same piece of
> code is working for AD 2000.
>
>
>
> Any help for the above problem would be much appreciated.
>
> Any suggestion/ideas are welcome.
>
>
>
> if(bFlag)
>
> {
>
>       strServerName = " Server2003";
>
>       strAdminName = "snetadmin ";
>
>       strAdminPassword = "abc";
>
>       strDomainName = "a.com";
>
>       strRefPath = "LDAP://Server2003/CN=Mani Jain,OU=a,OU=Domain
> Controllers,DC=a,DC=com";
>
> }
>
> else
>
> {
>
>       strServerName = "Server2000";
>
>       strAdminName = "ServiceNetAdmin";
>
>       strAdminPassword = "sample";
>
>       strDomainName = "b.com";
>
>       strRefPath = 
> "LDAP://Server2000/CN=Mani,OU=b,OU=DomainControllers,DC=b,DC=com";
>
> }
>
>
>
> int iStart = strRefPath.IndexOf("CN=");
>
> int iEnd = strRefPath.IndexOf(",", iStart);
>
> string strValOU = "";
>
> if (iStart  > 0)
>
> {
>
>       strValOU = strRefPath.Substring(0, iStart);
>
> }
>
> if (iEnd > 0)
>
> {
>
>       strValOU = strValOU  +  strRefPath.Substring(iEnd + 1);
>
> }
>
> strServerPath = strValOU;
>
>
>
> DirectoryEntry objDirectoryEntry = new DirectoryEntry(strServerPath,
> strAdminName, strAdminPassword, AuthenticationTypes.Secure);
>
>
>
> //Add the User
>
> DirectoryEntries objDirectryEntries = objDirectoryEntry.Children;
>
> DirectoryEntry objNewDirectoryEntry = objDirectryEntries.Add("CN=" +
> txtUserName.Text.Trim(), "user");
>
>
>
> objNewDirectoryEntry.Properties["userPrincipalName"].Value =
> txtUserName.Text.Trim();
>
> objNewDirectoryEntry.Properties["samAccountName"].Value =
> txtUserName.Text.Trim();
>
> objNewDirectoryEntry.Properties["sn"].Value = "2";
>
> objNewDirectoryEntry.Properties["givenName"].Value = "A";
>
> objNewDirectoryEntry.Properties["UserPassword"].Value = "abc";
>
>
>
> objNewDirectoryEntry.CommitChanges();
>
> strServerPath = "LDAP://" + strServerName;
>
> if(bFlag)
>
> strServerPath = this.GetUserPath(txtUserName.Text.Trim() + "@" +
> strDomainName, strServerPath, strAdminName, strAdminPassword, bFlag);
>
> else
>
>       strServerPath = this.GetUserPath(txtUserName.Text.Trim(),
> strServerPath, strAdminName, strAdminPassword,bFlag);
>
>
>
> DirectoryEntry objDirectoryEntry1 = new DirectoryEntry(strServerPath,
> strAdminName, strAdminPassword, AuthenticationTypes.Secure);
>
> int iUAC = Convert.ToInt32(objDirectoryEntry1.Properties
> ["userAccountControl"].Value);
>
> iUAC = iUAC & ~(C_ADS_UF_ACCOUNTDISABLE); //Activate the account
>
> objDirectoryEntry1.Properties["userAccountControl"].Value =iUAC; //Reset
> the property.
>
> objDirectoryEntry1.CommitChanges();
>
>
>
> Regards,
> krishnan
>
>
> [Non-text portions of this message have been removed]
>
>
>
>  SPONSORED LINKS
>   Basic programming 
> language<http://groups.yahoo.com/gads?t=ms&k=Basic+programming+language&w1=Basic+programming+language&w2=Computer+programming+languages&w3=Programming+languages&w4=Java+programming+language&c=4&s=126&.sig=bnac3LCZpttb3c9FvbVU-A>
>   Computer
> programming 
> languages<http://groups.yahoo.com/gads?t=ms&k=Computer+programming+languages&w1=Basic+programming+language&w2=Computer+programming+languages&w3=Programming+languages&w4=Java+programming+language&c=4&s=126&.sig=1Czd2hKCO9_u4KVZQperFQ>
>   Programming
> languages<http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=Basic+programming+language&w2=Computer+programming+languages&w3=Programming+languages&w4=Java+programming+language&c=4&s=126&.sig=TyHGCjod4YOKITrSq1xccQ>
>    Java
> programming 
> language<http://groups.yahoo.com/gads?t=ms&k=Java+programming+language&w1=Basic+programming+language&w2=Computer+programming+languages&w3=Programming+languages&w4=Java+programming+language&c=4&s=126&.sig=PZAexF9LyXpKb3HDJSlB1g>
>  ------------------------------
> YAHOO! GROUPS LINKS
>
>
>    -  Visit your group 
> "AspNetAnyQuestionIsOk<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk>"
>    on the web.
>
>    -  To unsubscribe from this group, send an email to:
>     [EMAIL PROTECTED]<[EMAIL PROTECTED]>
>
>    -  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>    Service <http://docs.yahoo.com/info/terms/>.
>
>
>  ------------------------------
>


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/2jUsvC/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to