Click here to Skip to main content
15,912,021 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionGet N words of a string Pin
shapper29-Sep-06 14:45
shapper29-Sep-06 14:45 
AnswerRe: Get N words of a string Pin
Not Active29-Sep-06 15:39
mentorNot Active29-Sep-06 15:39 
GeneralRe: Get N words of a string Pin
Guffa29-Sep-06 22:51
Guffa29-Sep-06 22:51 
GeneralRe: Get N words of a string Pin
shapper30-Sep-06 2:13
shapper30-Sep-06 2:13 
AnswerRe: Get N words of a string Pin
Guffa1-Oct-06 8:49
Guffa1-Oct-06 8:49 
GeneralRe: Get N words of a string Pin
Not Active30-Sep-06 2:53
mentorNot Active30-Sep-06 2:53 
QuestionCaution against using System.Drawing namespace in ASP.NET Pin
Peter Josefsson Sweden29-Sep-06 12:59
Peter Josefsson Sweden29-Sep-06 12:59 
QuestionActive Directory User Creation Pin
legionnaire29-Sep-06 12:07
legionnaire29-Sep-06 12:07 
Hello there,

I've been working on a small Web Service for my school to allow me to create users in an Active Directory. What I've been doing as my - probably faulty - developing process is to create a Windows Application and when the code is working correctly, I copy it to my Web Service code, fine tune it, and it's ready to go.

But the odd thing here is that when my code creates a user in the domain through the WebService, it creates the user with its account disabled even when I have put code to explicitly enable the account. Yet, if I run the same exact code from the Windows App, it creates the user account enabled.

I don't know if it's a question that has been answered before, or if for some security reason that's the way Web Services create user account by default.

Oh! By the by, the Web Service is running on a machine with Windows 2000 Professional, with the .Net 2.0 framework installed an configured; whereas the app in which I tried the code runs on a Win XP machine. Both machines are members of my school's domain. Maybe that has to do with it.

private void addUser(string user, string name, string lastName, string password)<br />
    {<br />
        try<br />
        {<br />
            DirectoryEntry adUserFolder = new DirectoryEntry("LDAP://10.32.62.9/CN=Users,DC=some,DC=domain,DC=here", "someuse", "somepassword");<br />
            if (adUserFolder.SchemaEntry.Name == "container")<br />
            {<br />
                DirectoryEntry newUser = adUserFolder.Children.Add("CN=" + user, "User");<br />
<br />
                DirectorySearcher search = new DirectorySearcher(adUserFolder);<br />
                search.SearchScope = SearchScope.Subtree;<br />
                search.Filter = "(&(ObjectClass=user)(cn=" + user + "))";<br />
                SearchResultCollection res = search.FindAll();<br />
                if (res.Count > 0)<br />
                {<br />
                  //ignore this, we still have not decided how to work with already existing users  <br />
//adUserFolder.Children.Remove(newUser);<br />
                    return;<br />
                }<br />
<br />
                newUser.Properties["sAMAccountName"].Value = useer;<br />
                newUser.Properties["givenName"].Value = name;<br />
                newUser.Properties["SN"].Value = lastName;<br />
                newUser.Properties["displayName"].Value = name + " " + lastName;<br />
<br />
                newUser.CommitChanges();<br />
<br />
                newUser.Invoke("setpassword", password); newUser.CommitChanges();<br />
<br />
                newUser.Properties["userAccountControl"].Value  = 0x200;<br />
<br />
                newUser.CommitChanges();<br />
            }<br />
        }<br />
        catch (DirectoryServicesCOMException e)<br />
        { Console.WriteLine(e.Message); }<br />
        catch (Exception e)<br />
        { Console.WriteLine(e.Message); }<br />
    }<br />
<br />


Thanks in advance!
AnswerRe: Active Directory User Creation Pin
legionnaire2-Oct-06 5:51
legionnaire2-Oct-06 5:51 
GeneralRe: Active Directory User Creation Pin
legionnaire2-Oct-06 6:24
legionnaire2-Oct-06 6:24 
QuestionFile Download Response..... Pin
Neo7869229-Sep-06 9:35
Neo7869229-Sep-06 9:35 
AnswerRe: File Download Response..... Pin
Jim Conigliaro29-Sep-06 10:45
Jim Conigliaro29-Sep-06 10:45 
QuestionRe: File Download Response..... Pin
Neo7869230-Sep-06 4:51
Neo7869230-Sep-06 4:51 
QuestionInherited TreeView Nodes and typeof Pin
perlmunger29-Sep-06 7:48
perlmunger29-Sep-06 7:48 
AnswerRe: Inherited TreeView Nodes and typeof Pin
minhpc_bk29-Sep-06 15:03
minhpc_bk29-Sep-06 15:03 
GeneralRe: Inherited TreeView Nodes and typeof Pin
perlmunger30-Sep-06 9:29
perlmunger30-Sep-06 9:29 
GeneralRe: Inherited TreeView Nodes and typeof Pin
minhpc_bk1-Oct-06 2:43
minhpc_bk1-Oct-06 2:43 
QuestionTableAdapter info Pin
robert11029-Sep-06 7:40
robert11029-Sep-06 7:40 
AnswerRe: TableAdapter info Pin
Not Active29-Sep-06 7:58
mentorNot Active29-Sep-06 7:58 
AnswerRe: TableAdapter info Pin
sanju027629-Sep-06 9:34
sanju027629-Sep-06 9:34 
Questionphp Pin
amaneet29-Sep-06 6:39
amaneet29-Sep-06 6:39 
AnswerRe: php Pin
nguyenvhn29-Sep-06 16:24
nguyenvhn29-Sep-06 16:24 
Questionphp Pin
amaneet29-Sep-06 6:25
amaneet29-Sep-06 6:25 
AnswerRe: php Pin
Not Active29-Sep-06 7:35
mentorNot Active29-Sep-06 7:35 
QuestionWeb Control Designing Questions Pin
Xiaoming Qian29-Sep-06 4:41
Xiaoming Qian29-Sep-06 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.