Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 321723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:52:19+00:00 2026-05-12T08:52:19+00:00

EDIT ive got it almost, having and error message now that it can’t find

  • 0

EDIT
ive got it almost, having and error message now that it can’t find the exchange DB. I’m running the service on a different server then Exchange so I presume I have to use an UNC path. MyServer01\First Storage Group\Mailbox Database.edb does not work though…

Hi!
I’m getting frustrated here, feeling a massive headache coming up and I am nearly at the point to throw my PC out of the window…

This is the issue, I want to create a new user in the Active Directory via Sharepoint, underneath the Sharepoint list runs a worflow which catches the variabeles and sends them to a webservice which creates the user in active directory. This works perfectly, but the user also needs a mailbox.
So, what do we do? We set the mail property to the needed e-mail address and find the property “Create Mailbox” …. say whut? where is it? NOOOOOESSS it does not exist anymore, MS decided that it needs to be more complicated and now the only way to do this is using the powershell crap…

So thats why I am here, I googled some info on this and found some code which should do the trick, but, and thats where I am stuck, the webservice does not run on the Exchange server but on a different server, the webservice needsw to connect to the exchange server to run the powershellshizzle… can’t find any info on this, can’t find any examples and so on…

hlep… F1… etc

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:52:19+00:00Added an answer on May 12, 2026 at 8:52 am

    This post explains what’s going. Basically, there used to be something in Exch2003 called the RUS which created the mailbox for ‘partially provisioned’ users. So you could create a user over LDAP, the and the RUS would pick the new user up on its next pass and complete the process by creating the mailbox and fixing up its other AD attributes.

    Now in 2007 the RUS is gone, but you can get the same functionality by scheduling some cmdlets to run periodically (eg with the ‘at’ command) on the Exchange server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 172k
  • Answers 172k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your problem may be that the execution of main thread… May 12, 2026 at 2:34 pm
  • Editorial Team
    Editorial Team added an answer If you every need to port to another vendor's database,… May 12, 2026 at 2:34 pm
  • Editorial Team
    Editorial Team added an answer Review the Picasa Web Albums Data API: http://support.google.com/picasa/answer/1224181?hl=en-GB https://developers.google.com/picasa-web/faq#quota If… May 12, 2026 at 2:34 pm

Related Questions

EDIT ive got it almost, having and error message now that it can't find
I've had this intermittent issue when using asp.net. My site is dynamically compiled. Sometimes
I've got a pretty strong background in C-style languages. And have worked on several
so I've been programming in C++ for almost 2 years now, and the whole
I've tried several variations of ASP & PHP native & 3rd party mailer programs.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.