Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get an attribute with Object(DS-DN) syntax #49

Open
freedman1002 opened this issue Mar 7, 2018 · 1 comment
Open

Get an attribute with Object(DS-DN) syntax #49

freedman1002 opened this issue Mar 7, 2018 · 1 comment

Comments

@freedman1002
Copy link

Hi,
I'm trying to get some extra attributes in result of Get-ADDBAccount -All.
attributes with String(Unicode) syntax added easily,
but I can't change source code to get attributes with Object(DS-DN) syntax like "Member".
what should I do?

@GuyTe
Copy link

GuyTe commented Apr 10, 2018

The C# code we use for something similar is:
(for multi-valued attributes you need to iterate over byte[][] and parse each byte[] to DsName)
`

    public DsName(byte[] binaryVal)
    {
        int currPos = 0;
        StructLength = BitConverter.ToUInt32(binaryVal, currPos);
        currPos = 4;
        _sidLength = BitConverter.ToUInt32(binaryVal.Skip(currPos).Take(4).ToArray(), 0);
        currPos += 4;

        byte[] guidBytes = binaryVal.Skip(currPos).Take(16).ToArray();
        ObjectGuid = new Guid(guidBytes);
        currPos += 16;

        // The size of this field is exactly 28 bytes, regardless of the value of SidLen, 
        // which specifies how many bytes in this field are used.
        byte[] sidBytes = binaryVal.Skip(currPos).Take(28).ToArray();
        Sid = (_sidLength > 0) ? new SecurityIdentifier(sidBytes, 0) : null;
        currPos += 28;

        _nameLength = BitConverter.ToUInt32(binaryVal.Skip(currPos).Take(4).ToArray(), 0);
        currPos += 4;

        DistinguishedName = Encoding.Unicode.GetString(binaryVal.Skip(currPos).Take((int)(_nameLength*2)).ToArray());
    }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants