2009-05-20 7 views
1

EDIT 交換DBが見つかりません。私は別のサーバーでExchangeを実行しているので、UNCパスを使用する必要があると推測します。 MyServer01 \最初のストレージグループ\メールボックスDatabase.edbは、しかし...リモートExchange 2007サーバー上のWebサービス経由でユーザーのメールボックスを作成します。 (C#)



こんにちは動作しません! 私はここに大声で頭痛が起きていると感じて、私はほとんど窓の外に私のPCを投げることになっています...

これは問題です、私は新しいユーザーを作成したいですSharepoint経由のActive Directoryは、Sharepointリストの下で、variabelをキャッチして、それらをActive Directoryにユーザを作成するWebサービスに送信するワームフローを実行します。これは完全に機能しますが、ユーザーはメールボックスも必要とします。 だから、私たちは何をしますか?メールプロパティを必要な電子メールアドレスに設定し、プロパティ "メールボックスの作成"を見つけました....それはどこにある?それはもう存在しないので、MSはより複雑にする必要があると判断しました。これを行う唯一の方法は、パワーシェルのクラップを使用することです...

私はここにいるので、私は立ち往生しなければならないいくつかのコードが見つかりましたが、私は立ち往生している、webserviceは、Exchangeサーバー上で実行されていないが、別のサーバー上で、powershellshizzleを実行するExchangeサーバーに接続するwebservice needsw ... 「がtは任意の例のように...

HLEP ... F1を...見つけることができない、この上の任意の情報を見つけるなど

using System; 
using System.Collections.Generic; 
using System.Collections.Specialized; 
using System.Linq; 
using System.Web; 
using System.Management.Automation; 
using System.Management.Automation.Host; 
using System.Management.Automation.Runspaces; 
using Microsoft.PowerShell.Commands; 
using System.Web.Services; 
using System.DirectoryServices; 

namespace WebService1 
{ 
/// <summary> 
/// Summary description for Service1 
/// </summary> 
[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[System.ComponentModel.ToolboxItem(false)] 
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService] 
public class Service1 : System.Web.Services.WebService 
{ 

    [WebMethod] 
    public void CreateADUser(string domain, string domainPostFix, string firstName, string emailaddress, string lastName, string department, string loginName, string password) 
    { 
     DirectoryEntry AD = null; 
     DirectoryEntry NewUser = null; 

     AD = new DirectoryEntry("LDAP://OU=Users,DC=" + domain + ",DC=" + domainPostFix); 

     NewUser = AD.Children.Add("CN=" + firstName + " " + lastName, "user"); 
     NewUser.Properties["samAccountName"].Add(loginName); 
     NewUser.Properties["name"].Add(firstName + " " + lastName); 
     NewUser.Properties["displayname"].Add(firstName + " " + lastName); 
     NewUser.Properties["givenName"].Add(firstName); 
     NewUser.Properties["sn"].Add(lastName); 
     NewUser.Properties["userprincipalname"].Add(loginName + "@" + domain + "." + domainPostFix); 
     NewUser.CommitChanges(); 

     NewUser.Invoke("SetPassword", new object[] { password }); 

     NewUser.CommitChanges(); 

     // E-mail shizzle, don't understand it yet, hopefully it works, if not, don't blame me -Erik 
     RunspaceConfiguration runspaceConf = RunspaceConfiguration.Create(); 
     PSSnapInException PSException = null; 
     PSSnapInInfo info = runspaceConf.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out PSException); 
     Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConf); 
     runspace.Open(); 
     Pipeline pipeline = runspace.CreatePipeline(); 
     Command command = new Command("New-Mailbox"); 
     command.Parameters.Add("Name", "TestName"); 

     //Enabling user account 
     int val = (int)NewUser.Properties["userAccountControl"].Value; 
     NewUser.Properties["userAccountControl"].Value = val & ~0x2; 
     NewUser.CommitChanges(); 

     NewUser.Close(); 


    } 

答えて

1

This postは何が起こっているのかを説明します。基本的に、Exch2003には、部分的にプロビジョニングされたユーザー用のメールボックスを作成したRUSというものがありました。したがって、LDAP上でユーザーを作成すると、RUSは次のパスで新しいユーザーを選択し、メールボックスを作成して他のAD属性を修正することでプロセスを完了します。

2007年にRUSは廃止されましたが、Exchangeサーバー上で定期的に(たとえば 'at'コマンドを使用して)実行するコマンドレットをスケジュールすることで同じ機能を利用できます。

0

マシンExchange管理スナップインを使用できるように、Exchange管理ツールをインストールする必要がある場合にこのアプリケーションを実行しています。

実行しているアカウントにもExchangeの管理者特権が必要です。

関連する問題