Re: DirectoryEntry.Invoke("SetPassword") slow
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 08/29/04
- Next message: Nick Malik: "Re: Why did Microsoft limited itself to Windows?"
- Previous message: RichM: "Selling a class library"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 29 Aug 2004 15:06:07 -0500
It could be related to an SSL problem on the server. SetPassword tries to
use SSL/LDAP under the hood to create an encrypted channel to the server.
Sometimes SSL binds can be slow due to client certificates and such. I'd
check the event log on the machine making the call for Schannel errors in
the System log.
Joe K.
"Oleg Ogurok" <oleg@ogurok.com.ihatespammers.ireallydo.co> wrote in message
news:10j27ll4hr4699a@corp.supernews.com...
> Hi all,
>
> I'm having problems setting password for user in Active Directory via
> LDAP/ADSI.
> In one environment it works fine, on another domain this line takes a
minute
> or two to execute:
> Invoke("SetPassword", new object[] { pass }).
>
> Any other line executes quickly.
> The code never fails, it just takes long time to finish.
>
> Here's my code:
>
> public void AddUser(string userName, string domain, string firstName,
> string lastName, string password)
> {
> using (DirectoryEntry adminEntry = new DirectoryEntry(ldapPath, null,
> null, AuthenticationTypes.Secure))
> {
> object native = entry.NativeObject; // to force auth
> string fullName = firstName + " " + lastName;
> using (DirectoryEntry deUser = adminEntry.Children.Add("cn=" +
fullName,
> "user"))
> {
> string domainAndUserName = userName + "@" + domain;
>
> deUser.Properties["userPrincipalName"].Add(domainAndUserName);
> deUser.Properties["sAMAccountName"].Add(userName);
> deUser.Properties["sn"].Add(lastName);
> deUser.Properties["displayName"].Add(fullName);
> deUser.Properties["givenName"].Add(firstName);
> deUser.Properties["description"].Add("Added via MyProgram");
> deUser.CommitChanges();
> // User has to be saved prior to this step
> deUser.Invoke("SetPassword", new object[] {password} ); // THIS LINE
> IS SLOW !!!!
>
> // Create a normal account and enable it - ADS_UF_NORMAL_ACCOUNT
> deUser.Properties["userAccountControl"].Value = 0x200;
> deUser.CommitChanges();
> }
> }
> }
>
>
> Thanks,
> -Oleg.
>
>
- Next message: Nick Malik: "Re: Why did Microsoft limited itself to Windows?"
- Previous message: RichM: "Selling a class library"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|