windows server 2003 : Add domain user to local group RRS feed

  • Question

  • Hi All,
     I was a bit confused about on which forum to ask a question ...

    Here is my problem ...

    I have an user (user@org.com) created in Active Directory under Ad -> Hosting -> OrgOU

    Also, I have one local group Local_Ad_Group under Local Users and Groups

    Machine is : Windows Server 2003 R2 Enterprise edition x32bit
    User Login: Administrator/Password.

    When I tried to add domain user to local group I am getting following error ...

    A member could not be added to or removed from the local group because the member does not exist

    Both user and Group are exists.
    i.e. User is present in AD under the given OU above, also the Group is present in Local User & Groups (My Computer, right click  -> manage ->system tools)

    Code is compiling correctly.

    ADSIUtil.PDC and Environement.MachineName are references used to get the AD and machine names.
    Paths retrieved from the code are correct.

    C# Code  :->

    private void InternalAddRemoveUserToGroup(string username, string group) {
    DirectoryEntry direntgrouproot = null;
    DirectoryEntry direntuserroot = null;
    DirectoryEntry direntuser = null;
    DirectoryEntry direntgrp = null;        

    direntgrouproot = new DirectoryEntry("WinNT://" + Environment.MachineName + ",group");

    direntuserroot = new DirectoryEntry("WinNT://" + ADSIUtil.PDC + ",User");

    direntuser = direntuserroot.Children.Find(username, "User");
    direntgrp = direntgrouproot.Children.Find(group, "group");

    direntgrp.Invoke("Add", new Object[] { direntuser.Path.ToString() });


    I am getting following details for user and group ...

    I am using the user AD path as WinNT://Domain/AD1/test123#org.dom

    and Group Path as WinNT://Domain/WEBHOST1/WVH_AD_USERS_GROUP

    where webhost1 is the machine name.

    I am not using any FQDN here, most of the blogs and forums suggest not to use FQDN.
    I tried with both.

    Tuesday, June 30, 2009 5:30 AM