locked
2 Easy Questions (I think???) RRS feed

  • Question

  • User2060040125 posted
    I'm using ASP.NET 1.1 and ADAM. 

    First Easy Question:
    I want to create a user where the password doesn't expire.  However I'm getting this error "Object reference not set to an instance of an object".  I'm using the following code:
    =================================================
                string sPath = "";       
                DirectoryEntry objGroup;  // Group object.   
                DirectoryEntry objUser;
                       
                objUser = Base.Children.Add("CN=" + User + ",OU=Members", "user");
                objGroup = new DirectoryEntry("LDAP://" + ADAMServer + ":" + Port + "/CN=Readers,CN=Roles,O=UGL",
                                              UserName, ADAMPassword,AuthenticationTypes.SecureSocketsLayer );   
                   
                sPath = objUser.Path.Substring(objUser.Path.IndexOf("/CN=") + 1);           

                if (WebInitialSetup!="") objUser.Properties["adminDescription"].Add(WebInitialSetup);           
                if (AccountStatus!="") objUser.Properties["st"].Add(AccountStatus);
                if (ContraxID!="") objUser.Properties["comment"].Add(ContraxID);
                if (FirstName!="") objUser.Properties["givenName"].Add(FirstName);
                if (DisplayName!="") objUser.Properties["displayName"].Add(DisplayName);
                if (Email!="") objUser.Properties["mail"].Add(Email);
                if (LastName!="") objUser.Properties["sn"].Add(LastName);
                objUser.Properties["userPassword"].Value = Password;
                objUser.Properties["employeeType"].Add(EmployeeType);
                //    objUser.Properties["msDS-UserDontExpirePassword"].Add("True");
                int exp = (int) objUser.Properties["userAccountControl"].Value;
                objUser.Properties["userAccountControl"].Value = exp | 0x0001;

                objUser.CommitChanges();

    =================================================
    Do I have to commitChanges first?

    2nd easy question:
    Ho
    w do I get the last time a user logged in?  I've done this in VB using the difference between PwdLastSet.LowPart and PwdLastSet.HighPart of a IADs object.  However, I can't seem to find similiar property/method in the DirectoryEntry class.


    Any help would be greatly appreciated,

    Thanks, Bill_N


    Wednesday, June 7, 2006 12:12 PM

All replies

  • User1354132231 posted
    1.) I think the issue might be that 'userAccountControl' is missing from ADAM.
    2.) You can still do the same thing, but it turns out to be easier using SearchResult.

    Short answers, I know.  For the (very) long answer that should drive home each one, please read my sample chapter that covers both of these issues in-depth.  You can find the sample chapter by following the links from the first post for Samples in this forum.  This post has a link to the book's website at either publisher or companion site that contains a link to a sample chapter on user management.  It specifically covers what you are asking.

    Good luck!



    Wednesday, June 7, 2006 1:53 PM
  • User2060040125 posted
    Thanks for the reply.

    Where's the sample chapter?  The link you posted is to this question.

    Thanks Again,
    Bill_N
    Wednesday, June 7, 2006 2:49 PM
  • User1354132231 posted
    Sorry about that, it was the first post in the forum here:

    http://forums.asp.net/thread/1284725.aspx

    I updated my last response just in case some one comes along later.
    Wednesday, June 7, 2006 2:54 PM
  • User2060040125 posted
    Sorry I think I found it at http://www.awprofessional.com/content/images/0321350170/samplechapter/Kaplan_ch10.pdf

    If this is incorrect please notify me.

    Thanks, Bill_N

    Wednesday, June 7, 2006 3:02 PM