Je reçois une erreur d'application Web qui permet aux utilisateurs de l'intranet d'entreprise de mettre à jour les détails de leur répertoire actif (numéros de téléphone, etc.).Mise à jour d'Active Directory à partir de l'application Web Erreur
L'application Web est hébergée sur IIS6 exécutant Windows Server 2003 (SP1). Le site Web IIS utilise l'authentification NTLM et la sécurité intégrée est activée sur le site Web. Le pool d'applications IIS s'exécute en utilisant le compte "Service réseau".
Le web.config contient les éléments suivants
<LdapConfigurations server="xxx.internal" root="OU=Staff Accounts,DC=xxx,DC=internal" domain="xxx" />
<identify impersonate=”true” />
Code délégation Active Directory n'est pas nécessaire que les éléments suivants C# (.NET 3.5) devrait transmettre les détails de l'usurpation d'identité correcte (y compris jeton de sécurité) sur Active Directory .
public void UpdateData(string bus, string bus2, string fax, string home, string home2, string mob, string pager, string notes)
{
WindowsIdentity windId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = null;
try
{
ctx = windId.Impersonate();
DirectorySearcher ds = new DirectorySearcher();
DirectoryEntry de = new DirectoryEntry();
ds.Filter = m_LdapUserFilter;
// i think this is the line causing the error
de.Path = ds.FindOne().Path;
this.AssignPropertyValue(bus, ADProperties.Business, ref de);
this.AssignPropertyValue(bus2, ADProperties.Business2, ref de);
this.AssignPropertyValue(fax, ADProperties.Fax, ref de);
this.AssignPropertyValue(home, ADProperties.Home, ref de);
this.AssignPropertyValue(home2, ADProperties.Home2, ref de);
this.AssignPropertyValue(mob, ADProperties.Mobile, ref de);
this.AssignPropertyValue(pager, ADProperties.Pager, ref de);
this.AssignPropertyValue(notes, ADProperties.Notes, ref de);
// this may also be causing the error?
de.CommitChanges();
}
finally
{
if (ctx != null)
{
ctx.Undo();
}
}
}
private void AssignPropertyValue(string number, string propertyName, ref DirectoryEntry de)
{
if (number.Length == 0 && de.Properties[propertyName].Value != null)
{
de.Properties[propertyName].Remove(de.Properties[propertyName].Value);
}
else if (number.Length != 0)
{
de.Properties[propertyName].Value = number;
}
}
détails de l'utilisateur peuvent être récupérées à partir d'Active Directory sans problème mais la question se pose lorsque la mise à jour des utilisateurs Détails de l'annonce. Le message d'exception suivant est affiché.
System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
at xxx.UpdateData(String bus, String bus2, String fax, String home, String home2, String mob, String pager, String notes)
at xxx._Default.btnUpdate_Click(Object sender, EventArgs e)
Le code fonctionne très bien dans notre domaine de développement mais pas dans notre domaine de production. Quelqu'un peut-il aider à aider à résoudre ce problème?
J'ai vérifié dans les deux environnements, je suis seulement un membre du groupe "Domain Users". – Kane