T
Tina Smith
This sample code works perfectly in Console App. It will fail on the
Children.Add line when running the same code in a Web App. I'm assuming
it's a permissions issue but I can't see to solve it. Any help would be
appreciated.
----------------------------------------------------------------------------
--------------
Imports System.DirectoryServices
Module Module1
Sub Main()
Try
Dim AD As DirectoryEntry = _
New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")
Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
NewUser.Invoke("SetPassword", New Object() {"#12345Abc"})
NewUser.Invoke("Put", New Object() {"Description", "Test User from
..NET"})
NewUser.CommitChanges()
Dim grp As DirectoryEntry
grp = AD.Children.Find("Guests", "group")
If grp.Name <> "" Then
grp.Invoke("Add", New Object() {NewUser.Path.ToString()})
End If
Catch ex As Exception
End Try
End Sub
End Module
Children.Add line when running the same code in a Web App. I'm assuming
it's a permissions issue but I can't see to solve it. Any help would be
appreciated.
----------------------------------------------------------------------------
--------------
Imports System.DirectoryServices
Module Module1
Sub Main()
Try
Dim AD As DirectoryEntry = _
New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")
Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
NewUser.Invoke("SetPassword", New Object() {"#12345Abc"})
NewUser.Invoke("Put", New Object() {"Description", "Test User from
..NET"})
NewUser.CommitChanges()
Dim grp As DirectoryEntry
grp = AD.Children.Find("Guests", "group")
If grp.Name <> "" Then
grp.Invoke("Add", New Object() {NewUser.Path.ToString()})
End If
Catch ex As Exception
End Try
End Sub
End Module