Multiple python installations mix their sys.prefix

shrikant kesharwani shrikant12 at ymail.com
Mon Jan 24 07:19:08 EST 2011


Hi,
I have a web page through this page when I try to add a new user then users created successfully but when try resetting their password then I am getting errors?
add New user successfully
 public static void AddUser(ADUser adUser)
 {
 // Local variables
 DirectoryEntry oDE = null;
 DirectoryEntry oDENewUser = null;
 DirectoryEntries oDEs = null;
 try
 {
 oDE = GetDirectoryEntry(GetADPath(PROD, adUser.UserType));
 
 // 1. Create user account
 oDEs = oDE.Children;
 oDENewUser = oDEs.Add("CN=" + adUser.UserName, "user");
 
 // 2. Set properties
 SetProperty(oDENewUser, "givenName", adUser.FirstName);
 SetProperty(oDENewUser, "sn", adUser.LastName);
 SetProperty(oDENewUser, "mail", adUser.Email);
 SetProperty(oDENewUser, "sAMAccountName", adUser.UserName);
 oDENewUser.CommitChanges();
 /// 4. Enable account 
 EnableAccount(oDENewUser);
 // 3. Set password
 //SetPassword(oDENewUser, adUser.Password);
 SetPassword1(oDENewUser.Path, adUser.Password);
 oDENewUser.CommitChanges();
 oDENewUser.Close();
 oDE.Close();
 }
 catch (Exception ex)
 {
 throw ex;
 }
 }
I have try the following 2 SetPassword methods but getting error.
Method 1.
 internal static void SetPassword1(string path, string userPassword)
 {
 //Local variables
 DirectoryEntry usr = null;
 
 try
 {
 usr = new DirectoryEntry();
 usr.Path = path;
 usr.AuthenticationType = AuthenticationTypes.Secure;
 object ret = usr.Invoke("SetPassword", userPassword);
 usr.CommitChanges();
 usr.Close();
 }
 catch (Exception ex)
 {
 throw ex;
 }
 }
The exception raised (Error Code 80072035: The server is unwilling to process the request)
Method 2.
internal static void SetPassword(DirectoryEntry de, string userPassword)
 {
 //Local variables
 //DirectoryEntry usr = null;
 string quotePwd;
 byte[] pwdBin;
 
 try
 {
 quotePwd = String.Format(@"""{0}""", userPassword);
 pwdBin = System.Text.Encoding.Unicode.GetBytes(quotePwd);
 de.Properties["unicodePwd"].Value = pwdBin;
 de.CommitChanges();
 //usr.Close();
 }
 catch (Exception ex)
 {
 throw ex;
 }
 }
The exception raised ("Exception has been thrown by the target of an invocation.")
Is there an easy way to tell if there is a problem with changing a password?
Please reply me as soon as possible.
Thanks.
Submitted via EggHeadCafe 
JSONP AJAX and ASP.NET Demystified
http://www.eggheadcafe.com/tutorials/aspnet/b71ea548-93e0-4cec-9fb1-35f641b83e65/jsonp-ajax-and-aspnet-demystified.aspx


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /