Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[WSS] Connexion à un Active Directory depuis WP

3 réponses
Avatar
Antoine
Bonjour,

je cherche désespérément à réaliser une connexion à l'active directory pour
récupérer les informations d'un utilisateur.

Malheureusement, lorsque je déploie le WP, j'ai erreur du type The
"WebPart1" Web Part appears to be causing a problem.

1. Quelqu'un aurait-il eu le même soucis ?
2. Y-a-t'il des prérequis pour faire une connexion entre AD et Webpart WSS ?
3. Faut-il spécifier quelquechose à IIS pour que les connexions soient
acceptées ?

Merci par avance.

Webpart Source code:
-----------------------------------------------------------------
using System.DirectoryServices;
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization
;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebControls;

namespace WebPartLibrary5
{
...
protected override void RenderWebPart(HtmlTextWriter output)

{
DirectoryEntry Ldap = new DirectoryEntry("LDAP://AD-Name", "Login",
"Password");
DirectorySearcher searcher = new DirectorySearcher(Ldap);
searcher.Filter = "(objectClass=user)";

foreach( SearchResult result in searcher.FindAll
() )
{
DirectoryEntry DirEntry = result.GetDirectoryEntry();

output.WriteLine("Login : " + DirEntry.Properties["SAMAccountName"].Value);
output.WriteLine("Firstname : " + DirEntry.Properties["sn"].Value);
output.WriteLine("Lastname : " + DirEntry.Properties["givenName"].Value);
output.WriteLine("Email : " + DirEntry.Properties["mail"].Value);

output.WriteLine("Phone : " + DirEntry.Properties["TelephoneNumber"].Value);
output.WriteLine("Description : " + DirEntry.Properties["description"].Value);
output.WriteLine("-------------------");
}

}
}

3 réponses

Avatar
EROL MVP SPS - Club SharePoint
Bonjour Antoine,

Quel type de Web Part ?
Cdlt
--
EROL
http://www.clubsps.org
http://sharepointerol.blogspot.com/

Prochaine Réunion du Club SharePoint FRANCE ...
Pour vous inscrire gratuitement au club SPS,
cliquer ici : http://inscrits.clubsps.org/ .

"Antoine" a écrit dans le message de
news:
Bonjour,

je cherche désespérément à réaliser une connexion à l'active directory
pour
récupérer les informations d'un utilisateur.

Malheureusement, lorsque je déploie le WP, j'ai erreur du type The
"WebPart1" Web Part appears to be causing a problem.

1. Quelqu'un aurait-il eu le même soucis ?
2. Y-a-t'il des prérequis pour faire une connexion entre AD et Webpart WSS
?
3. Faut-il spécifier quelquechose à IIS pour que les connexions soient
acceptées ?

Merci par avance.

Webpart Source code:
-----------------------------------------------------------------
using System.DirectoryServices;
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization
;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebControls;

namespace WebPartLibrary5
{
...
protected override void RenderWebPart(HtmlTextWriter output)

{
DirectoryEntry Ldap = new DirectoryEntry("LDAP://AD-Name", "Login",
"Password");
DirectorySearcher searcher = new DirectorySearcher(Ldap);
searcher.Filter = "(objectClass=user)";

foreach( SearchResult result in searcher.FindAll
() )
{
DirectoryEntry DirEntry = result.GetDirectoryEntry();

output.WriteLine("Login : " +
DirEntry.Properties["SAMAccountName"].Value);
output.WriteLine("Firstname : " + DirEntry.Properties["sn"].Value);
output.WriteLine("Lastname : " + DirEntry.Properties["givenName"].Value);
output.WriteLine("Email : " + DirEntry.Properties["mail"].Value);

output.WriteLine("Phone : " +
DirEntry.Properties["TelephoneNumber"].Value);
output.WriteLine("Description : " +
DirEntry.Properties["description"].Value);
output.WriteLine("-------------------");
}

}
}


Avatar
Antoine
C'est à dire ??
Qu'entends-tu par type de Webpart ?

Mon projet repose sur le template de Webpart (Visual Studio 2003) par défaut
de Microsoft.
Dans mon Webpart, je souhaite intérroger l'active directory pour récupérer
des informations et en fonction du résultat afficher une page différente à
chaque fois.




"EROL MVP SPS - Club SharePoint" wrote:

Bonjour Antoine,

Quel type de Web Part ?
Cdlt
--
EROL
http://www.clubsps.org
http://sharepointerol.blogspot.com/

Prochaine Réunion du Club SharePoint FRANCE ...
Pour vous inscrire gratuitement au club SPS,
cliquer ici : http://inscrits.clubsps.org/ .

"Antoine" a écrit dans le message de
news:
> Bonjour,
>
> je cherche désespérément à réaliser une connexion à l'active directory
> pour
> récupérer les informations d'un utilisateur.
>
> Malheureusement, lorsque je déploie le WP, j'ai erreur du type The
> "WebPart1" Web Part appears to be causing a problem.
>
> 1. Quelqu'un aurait-il eu le même soucis ?
> 2. Y-a-t'il des prérequis pour faire une connexion entre AD et Webpart WSS
> ?
> 3. Faut-il spécifier quelquechose à IIS pour que les connexions soient
> acceptées ?
>
> Merci par avance.
>
> Webpart Source code:
> -----------------------------------------------------------------
> using System.DirectoryServices;
> using System;
> using System.ComponentModel;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Xml.Serialization
> ;
> using Microsoft.SharePoint;
> using Microsoft.SharePoint.Utilities;
> using Microsoft.SharePoint.WebPartPages;
> using Microsoft.SharePoint.WebControls;
>
> namespace WebPartLibrary5
> {
> ...
> protected override void RenderWebPart(HtmlTextWriter output)
>
> {
> DirectoryEntry Ldap = new DirectoryEntry("LDAP://AD-Name", "Login",
> "Password");
> DirectorySearcher searcher = new DirectorySearcher(Ldap);
> searcher.Filter = "(objectClass=user)";
>
> foreach( SearchResult result in searcher.FindAll
> () )
> {
> DirectoryEntry DirEntry = result.GetDirectoryEntry();
>
> output.WriteLine("Login : " +
> DirEntry.Properties["SAMAccountName"].Value);
> output.WriteLine("Firstname : " + DirEntry.Properties["sn"].Value);
> output.WriteLine("Lastname : " + DirEntry.Properties["givenName"].Value);
> output.WriteLine("Email : " + DirEntry.Properties["mail"].Value);
>
> output.WriteLine("Phone : " +
> DirEntry.Properties["TelephoneNumber"].Value);
> output.WriteLine("Description : " +
> DirEntry.Properties["description"].Value);
> output.WriteLine("-------------------");
> }
>
> }
> }





Avatar
AnthonyB
Je vous conseille vivement de mettre un bloc try/catch pour capter les erreurs.

Cela permettra de diagnostiquer le pb rencontré.
A mon avis, dans ce contexte, le pb est souvent dû à la sécurité d'accès à
votre AD.

Tester ce petit bout de code dans une appli WinForms pour valider que cela
marche.

AnthonyB

"Antoine" a écrit :

C'est à dire ??
Qu'entends-tu par type de Webpart ?

Mon projet repose sur le template de Webpart (Visual Studio 2003) par défaut
de Microsoft.
Dans mon Webpart, je souhaite intérroger l'active directory pour récupérer
des informations et en fonction du résultat afficher une page différente à
chaque fois.




"EROL MVP SPS - Club SharePoint" wrote:

> Bonjour Antoine,
>
> Quel type de Web Part ?
> Cdlt
> --
> EROL
> http://www.clubsps.org
> http://sharepointerol.blogspot.com/
>
> Prochaine Réunion du Club SharePoint FRANCE ...
> Pour vous inscrire gratuitement au club SPS,
> cliquer ici : http://inscrits.clubsps.org/ .
>
> "Antoine" a écrit dans le message de
> news:
> > Bonjour,
> >
> > je cherche désespérément à réaliser une connexion à l'active directory
> > pour
> > récupérer les informations d'un utilisateur.
> >
> > Malheureusement, lorsque je déploie le WP, j'ai erreur du type The
> > "WebPart1" Web Part appears to be causing a problem.
> >
> > 1. Quelqu'un aurait-il eu le même soucis ?
> > 2. Y-a-t'il des prérequis pour faire une connexion entre AD et Webpart WSS
> > ?
> > 3. Faut-il spécifier quelquechose à IIS pour que les connexions soient
> > acceptées ?
> >
> > Merci par avance.
> >
> > Webpart Source code:
> > -----------------------------------------------------------------
> > using System.DirectoryServices;
> > using System;
> > using System.ComponentModel;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Xml.Serialization
> > ;
> > using Microsoft.SharePoint;
> > using Microsoft.SharePoint.Utilities;
> > using Microsoft.SharePoint.WebPartPages;
> > using Microsoft.SharePoint.WebControls;
> >
> > namespace WebPartLibrary5
> > {
> > ...
> > protected override void RenderWebPart(HtmlTextWriter output)
> >
> > {
> > DirectoryEntry Ldap = new DirectoryEntry("LDAP://AD-Name", "Login",
> > "Password");
> > DirectorySearcher searcher = new DirectorySearcher(Ldap);
> > searcher.Filter = "(objectClass=user)";
> >
> > foreach( SearchResult result in searcher.FindAll
> > () )
> > {
> > DirectoryEntry DirEntry = result.GetDirectoryEntry();
> >
> > output.WriteLine("Login : " +
> > DirEntry.Properties["SAMAccountName"].Value);
> > output.WriteLine("Firstname : " + DirEntry.Properties["sn"].Value);
> > output.WriteLine("Lastname : " + DirEntry.Properties["givenName"].Value);
> > output.WriteLine("Email : " + DirEntry.Properties["mail"].Value);
> >
> > output.WriteLine("Phone : " +
> > DirEntry.Properties["TelephoneNumber"].Value);
> > output.WriteLine("Description : " +
> > DirEntry.Properties["description"].Value);
> > output.WriteLine("-------------------");
> > }
> >
> > }
> > }
>
>
>