Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 14, 2012 10:31 AM by Frank Jiang - MSFT
0 Points
8 Posts
Apr 11, 2012 06:19 PM|LINK
Hi all, I'm trying to manage an LDAP from another domain, from a web application.
I've read many posts but I'm not being able to make this work.
This is the peace of code which I'm using:
using (Impersonator impersonator = new Impersonator(userName, domainName, password)) { using (DirectoryEntry context = new DirectoryEntry(request.Path)) { context.AuthenticationType = AuthenticationTypes.Secure | AuthenticationTypes.ServerBind; context.Username = request.ClientUserName; context.Password = request.ClientPassword; using (DirectoryEntry newEntry = context.Children.Add("CN=" + newUser.Name, newUser.Type)) { ADHelper.SetDirectoryEntryProperties(newUser, newEntry); newEntry.CommitChanges(); } } }
Where ADHelper.SetDirectoryEntryProperties look like this:
directoryEntry.Properties["sAMAccountName"] = newUser.UserName; directoryEntry.Properties["givenName"] = newUser.FirstName; directoryEntry.Properties["sn"] = newUser.LastName; directoryEntry.CommitChanges(); directoryEntry.Invoke("SetPassword", new object[] { newUser.password }); directoryEntry.CommitChanges();
I'm getting this exception when SetPassword is invoked:
Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I can't figure out what's wrong.
I'll appreciate any clues.
Regards,
Daniel
setpassword ActiveDirectory
All-Star
16006 Points
1728 Posts
Microsoft
Apr 14, 2012 10:31 AM|LINK
The following thread may be useful to you:
http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a6c4e5d7-4265-4503-ace3-7513a61be564
Phylacterion
0 Points
8 Posts
DirectoryEntry Invoke SetPassword fails even Impersonating
Apr 11, 2012 06:19 PM|LINK
Hi all, I'm trying to manage an LDAP from another domain, from a web application.
I've read many posts but I'm not being able to make this work.
This is the peace of code which I'm using:
using (Impersonator impersonator = new Impersonator(userName, domainName, password)) { using (DirectoryEntry context = new DirectoryEntry(request.Path)) { context.AuthenticationType = AuthenticationTypes.Secure | AuthenticationTypes.ServerBind; context.Username = request.ClientUserName; context.Password = request.ClientPassword; using (DirectoryEntry newEntry = context.Children.Add("CN=" + newUser.Name, newUser.Type)) { ADHelper.SetDirectoryEntryProperties(newUser, newEntry); newEntry.CommitChanges(); } } }Where ADHelper.SetDirectoryEntryProperties look like this:
directoryEntry.Properties["sAMAccountName"] = newUser.UserName; directoryEntry.Properties["givenName"] = newUser.FirstName; directoryEntry.Properties["sn"] = newUser.LastName; directoryEntry.CommitChanges(); directoryEntry.Invoke("SetPassword", new object[] { newUser.password }); directoryEntry.CommitChanges();I'm getting this exception when SetPassword is invoked:
Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I can't figure out what's wrong.
I'll appreciate any clues.
Regards,
Daniel
setpassword ActiveDirectory
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: DirectoryEntry Invoke SetPassword fails even Impersonating
Apr 14, 2012 10:31 AM|LINK
The following thread may be useful to you:
http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a6c4e5d7-4265-4503-ace3-7513a61be564
setpassword ActiveDirectory
Feedback to us
Develop and promote your apps in Windows Store