AD Octet String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AstroDrabb

    AD Octet String

    I am trying to update some Active Directory attributes in C#. The C# app creates new computer objects and then populates some attributes. However, I am having problems with one attribute named netbootGUID, which is of type Octet String in AD. I haven't been able to find any working examples on the web. Part of the code follows:

    DirectoryEntry entry = new DirectoryEntry( path, m_UserName, m_Password);

    DirectoryEntry dChild = entry.Children. Add("CN=" + name, className);

    // add attributes
    dChild.Properti es["sAMAccountName "].Value = name + "$";
    dChild.Properti es["serialNumb er"].Value = serial;

    string guid = "4E435220000000 000000054012345 678"

    // this doesn't work
    dChild.Properti es["netbootGUI D"].Clear();
    dChild.Properti es["netbootGUI D"].Add(guid);
    // neither does this
    dChild.Properti es["netbootGUI D"].Value = guid;

    From what I can tell the netbootGUID attribute needs to be set as a byte[]. I tried converting the guid string to a byte[], I tried converting each char in guid to hex and then putting it into a byte[], however none of it has worked.

    Does anyone have an example of updating an Octet value in AD with C#?

    Thanks for any help.

    ---
    Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
  • AstroDrabb

    #2
    Re: AD Octet String

    For anyone who is interested, I found the solution.

    Mandatory attributes need to be written first and then you have to call CommitChanges() . For example:

    entry = new DirectoryEntry( path, m_UserName, m_Password);
    dChild = entry.Children. Add("CN=" + name, className);

    // add attributes
    dChild.Properti es["sAMAccountName "].Value = name + "$";
    dChild.Properti es["serialNumb er"].Value = serial;
    // new security in AD requires a commit here after setting
    // the mandatory attributes
    dChild.CommitCh anges();

    string guid = "4E435220-0000-0000-0000-054012345678"
    Guid myGuid1 = new Guid(guid);
    dChild.Properti es["netbootGUI D"].Clear();
    dChild.Properti es["netbootGUI D"].Add(myGuid1.To ByteArray());
    dChild.CommitCh anges();


    ---
    Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/

    Comment

    Working...