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

Urgent request...Thanks in advance.

Hi to all friends,

Friends i am new in this forums and also in c# programing

Acutally rightnow i make a software for my cable network, here i want to design login page for my client. who can enter his ID and password for using net serives..

so anybody tell me how to add user with using active directory.. ..?
Jul 23 '07 #1
2 1202
bartonc
6,596 Expert 4TB
Let's see what they have to say in the .NET Forum, shall we...
Jul 23 '07 #2
RoninZA
78
yasirrazza - You'll have to use the System.DirectoryServices namespace, if I'm not mistaken. Remember to add the reference to your project.

Google returned this example code:
Expand|Select|Wrap|Line Numbers
  1. public string CreateADSUser(string username, string password, string homedir)
  2.   {
  3.       String RootDSE;
  4.  
  5.       try
  6.       {
  7.         if (!Directory.Exists(homedir))
  8.           Directory.CreateDirectory(homedir);
  9.  
  10.         DirectorySearcher DSESearcher = new DirectorySearcher();
  11.         RootDSE = DSESearcher.SearchRoot.Path;
  12.  
  13.         RootDSE = RootDSE.Insert(7, "CN=Users,");
  14.  
  15.         DirectoryEntry myDE = new DirectoryEntry(RootDSE);
  16.         DirectoryEntries myEntries = myDE.Children;
  17.  
  18.         DirectoryEntry myDirectoryEntry = myEntries.Add("CN=" + username, "user");
  19.         myDirectoryEntry.Properties["userPrincipalName"].Value = username;
  20.         myDirectoryEntry.Properties["name"].Value = username;
  21.         myDirectoryEntry.Properties["Password"].Value = password;
  22.         myDirectoryEntry.Properties["samAccountName"].Value = username;
  23.         myDirectoryEntry.Properties["FullName"].Value = username;
  24.         myDirectoryEntry.Properties["AccountDisabled"].Value = 0;
  25.         myDirectoryEntry.Properties["PasswordRequired"].Value = 1;
  26.         myDirectoryEntry.Properties["HomeDirectory"].Value = homedir;
  27.  
  28.         // Permanent Password?
  29.         myDirectoryEntry.Properties["permpass"].Value = 1;
  30.         myDirectoryEntry.CommitChanges();
  31.  
  32.         DSESearcher.Dispose();
  33.         myDirectoryEntry.Dispose();
  34.  
  35.         return "Worked!";
  36.       }
  37.       catch (Exception ex)
  38.       {
  39.         return ex.Message;
  40.       }
  41.   }
  42.  
Jul 24 '07 #3

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

Similar topics

6
by: Rajesh Garg | last post by:
I have actually extended my request I have a scenario like this....... update esan set tes_address_city = 'TEST1' --at some time update esan set tes_address_city = 'TEST12' --at some time...
3
by: Niloday | last post by:
Hi All, I have developed a web service and deployed it on the Win2000 box. I can access the web methods of this web service when my client application is debugged from VS.NET studio. But it...
0
by: VS_NET_DEV | last post by:
Hi all, I am running asp.net on IIS 6.0 /IE 6.0 on Windows 2003 server. I have form authenication and in Global.asax I have: private void Global_AcquireRequestState(object sender,...
3
by: Vishal | last post by:
Hello, I have a URL like this: http://www.bla.com/login.aspx?url=....%0a.... now I need to remove the %0a, but it doesnt work. I tried this: <code>
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
2
by: Chandrakant Shinde | last post by:
Hi there, I want to copy a Image to the clipboard. When i try to do so following exception occurs : "The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be...
3
by: Bratislav Jevtic | last post by:
Hi, I've just installed Ajax November CTP, changed app according to instructions and I am (was) satisfied. Next step - deployment to server. I'm receiving error:...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.