Problem with DirectoryServices Access

Discussion in 'ASP .Net Security' started by Brian01, Mar 28, 2005.

  1. Brian01

    Brian01 Guest

    I have a Win2K server in a DMZ without domain access. My C# ASP.net page
    can not see the DirectoryServices namespace. I found a KB article on the
    security issue with this, but I don't have domain accounts to use from the
    DMZ, and don't want to set the machine.config properties for all aspx pages.
    I just want to set the password from a simple verification application that
    passes the user ID and password to the below page. Can this be done another
    way? Thanks for any assistance.

    <%@ Page Language="C#" Debug="true" %>
    <%@ import Namespace="System" %>
    <%@ import Namespace="System.DirectoryServices" %>

    <script runat="server">
    private void Page_Load (object sender, EventArgs e){

    String empNum = Session["lawEmpNum"].ToString();
    String newPassword = Session["password"].ToString();
    Response.Write("Employee Number is " + empNum);
    Response.Write("Password is " + newPassword);

    // correct the userPath!!!
    String userPath = "WinNT://localhost/" + empNum;
    using (DirectoryEntry userEntry = new DirectoryEntry(userPath))
    {
    object[] password = new object[] {newPassword};
    object ret = userEntry.Invoke("SetPassword", password );
    userEntry.CommitChanges();
    }
    Brian01, Mar 28, 2005
    #1
    1. Advertising

  2. You also need an assembly reference to System.DirectoryServices (use the
    assembly page directive or the equivalent stuff in web.config).

    Joe K.

    "Brian01" <> wrote in message
    news:...
    >
    > I have a Win2K server in a DMZ without domain access. My C# ASP.net page
    > can not see the DirectoryServices namespace. I found a KB article on the
    > security issue with this, but I don't have domain accounts to use from the
    > DMZ, and don't want to set the machine.config properties for all aspx
    > pages.
    > I just want to set the password from a simple verification application
    > that
    > passes the user ID and password to the below page. Can this be done
    > another
    > way? Thanks for any assistance.
    >
    > <%@ Page Language="C#" Debug="true" %>
    > <%@ import Namespace="System" %>
    > <%@ import Namespace="System.DirectoryServices" %>
    >
    > <script runat="server">
    > private void Page_Load (object sender, EventArgs e){
    >
    > String empNum = Session["lawEmpNum"].ToString();
    > String newPassword = Session["password"].ToString();
    > Response.Write("Employee Number is " + empNum);
    > Response.Write("Password is " + newPassword);
    >
    > // correct the userPath!!!
    > String userPath = "WinNT://localhost/" + empNum;
    > using (DirectoryEntry userEntry = new DirectoryEntry(userPath))
    > {
    > object[] password = new object[] {newPassword};
    > object ret = userEntry.Invoke("SetPassword", password );
    > userEntry.CommitChanges();
    > }
    >
    Joe Kaplan \(MVP - ADSI\), Mar 28, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edward
    Replies:
    1
    Views:
    2,397
    Edward
    Jul 8, 2003
  2. goldan
    Replies:
    1
    Views:
    459
    Patrick Olurotimi Ige
    Mar 9, 2005
  3. sck10
    Replies:
    2
    Views:
    10,391
    Steven Cheng[MSFT]
    Jun 10, 2005
  4. Replies:
    0
    Views:
    403
  5. Jason Huang

    ASPNet 2.0 DirectoryServices problem

    Jason Huang, Aug 23, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    Mark Rae [MVP]
    Aug 23, 2007
Loading...

Share This Page