Re: Add New Users
From: Scott Allen (scott_at_nospam.odetocode.com)
Date: 02/21/05
- Next message: IPGrunt: "Re: authentication problem"
- Previous message: Cowboy (Gregory A. Beamer) - MVP: "RE: IIS 6 and Windows Authentication to SQL Server 2000"
- In reply to: Tina Smith: "Add New Users"
- Next in thread: Cowboy (Gregory A. Beamer) - MVP: "RE: Add New Users"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 21 Feb 2005 15:25:34 -0500
Hi Tina:
Yes, this is a permissions issue. As a console app the code will send
your credentials to AD server, but when running under ASP.NET the code
executes under the local machine account ASPNET (or NETWORK SERVICE if
you are running asp.net on Win2003).
There are several possible solutions, one of which is to use
impersonation with a username and password in web.config.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaspnetimpersonation.asp
You might pick to run under a domain account with as limited
permissions as possible on the AD server.
-- Scott http://www.OdeToCode.com/blogs/scott/ On Mon, 21 Feb 2005 13:58:15 -0500, "Tina Smith" <tb.smith@earthlink.net> wrote: >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 >
- Next message: IPGrunt: "Re: authentication problem"
- Previous message: Cowboy (Gregory A. Beamer) - MVP: "RE: IIS 6 and Windows Authentication to SQL Server 2000"
- In reply to: Tina Smith: "Add New Users"
- Next in thread: Cowboy (Gregory A. Beamer) - MVP: "RE: Add New Users"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|