Bonjour,
Je viens vers vous car j'ai besoin d'aide pour une petite application que je développe en C# pour l'entreprise dans laquelle je suis en stage.
J'explique succintement :
C'est une application WPF qui servira entre autres à créer un compte utilisateur dans l'AD et, en lien avec ce compte, un compte Exchange 2010.
Concernant la création de l'utilisateur dans l'AD, c'est OK. Mais pour la création du compte Exchange j'ai quelques soucis.
J'ai déjà cherché partout sur le net et dans les forums mais je n'ai rien trouvé de concluant.
J'espère ne pas importuner en posant ma question et j'espère avoir bien choisi le topic.
Voici ma fonction de création de compte Exchange :
Donc quand j'appelle cette fonction, j'ai l'exception suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 /*** Exchange ***/ public static string CreateMail(string username, string adminUsrName, SecureString adminPwd, string domain) { PSCredential credential = new PSCredential(adminUsrName, adminPwd); // Set the connection Info string shellUri = "http://sbserver2011.training.local/Microsoft.Exchange"; string temp = "http://sbserver2011.training.local/Powershell"; Runspace runspace; WSManConnectionInfo connectionInfo = new WSManConnectionInfo((new Uri(shellUri)), temp, credential); connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic; runspace = RunspaceFactory.CreateRunspace(connectionInfo); PowerShell powershell = PowerShell.Create(); StringBuilder stringBuilder = new StringBuilder(); try { /*PSCommand cmdSession = new PSCommand(); cmdSession.AddCommand("New-PSSession"); cmdSession.AddParameter("ConnfigurationName", "Microsoft.Exchange"); cmdSession.AddParameter("ConnectionUri", "");*/ PSCommand cmdMailBox = new PSCommand(); cmdMailBox.AddCommand("Enable-Mailbox"); cmdMailBox.AddParameter("Identity", domain + "\\" + username); cmdMailBox.AddParameter("Database", "@mailboxDatabase"); powershell.Commands = cmdMailBox; runspace.Open(); powershell.Runspace = runspace; powershell.Invoke(); } catch (Exception ex) { String message = ex.Message; System.Windows.MessageBox.Show(message); //System.IO.File.WriteAllText(home + "\\log\\errors.log", message); } runspace.Dispose(); powershell.Dispose(); return stringBuilder.ToString(); }
"La connexion au serveur distant a échoué avec le message d'erreur suivant : Le client WinRM ne peut pas traiter la demande. Le trafic non chiffré est actuellement désactivé dans la configuration du client. Modifiez la configuration du client et renouvelez la demande."
Est-ce que quelqu'un saurait par hasard d'où provient le problème, et où on peut faire la configuration en question ?
Merci d'avance!!![]()
Partager