Question BigInt Conversion

Polynominal

New member
Joined
Nov 30, 2020
Messages
4
Programming Experience
Beginner
I have a field that I am referencing in Windows AD - its datatype bigint, I am using the code below in a SSIS package, I am getting System.__ComObject as the output

if (entry.Properties["pwdlastset"].Value != null)
{
Output0Buffer.Pwdlastsetdate = entry.Properties["pwdlastset"].Value.ToString();
}

Does anybody know a way of getting the correct output?

Thanks
 
See StackOverflow:

 
Post your code.
 
C#:
        if (entry.Properties["pwdlastset"].Value != null)
                    {
                        long value = (long)entry.Properties["pwdLastSet"][0];
                        DateTime pwdLastSet = DateTime.FromFileTimeUtc(value);
                        Output0Buffer.Pwdlastsetdate = pwdLastSet.ToString();
                    }
 
Last edited by a moderator:
insertcode3.png
 
This works for me:
C#:
var root = new DirectoryEntry(myLdapPath);
var searcher = new DirectorySearcher(root);
searcher.Filter = $"(SAMAccountName={myAccountName})";
var result = searcher.FindOne();
var cn = result.Properties["cn"][0];
Console.WriteLine($"{cn}");
var pwdLastSet = (long)result.Properties["pwdLastSet"][0];
Console.WriteLine($"{pwdLastSet}");
var lastSet = DateTime.FromFileTimeUtc(pwdLastSet);
Console.WriteLine($"{lastSet}");

Which produced the following output:
C#:
<redacted for privacy>
132515641876496955
12/04/2020 14:03:07

And yes, I did just change my password a few hours ago.
 
Hi Thanks for the above

How can I fit this into

if (entry.Properties["pwdlastset"].Value != null)
{
long value = (long)entry.Properties["pwdLastSet"][0];
DateTime pwdLastSet = DateTime.FromFileTimeUtc(value);
Output0Buffer.Pwdlastsetdate = pwdLastSet.ToString();
}
 
My lines 7-10 are essentially the same as your lines 3-5. I just posted that code to show that it things work as advertised by the StackOverflow article I originally linked to.

My recommendation is to actually use a debugger instead of just running your code. When you get to that line that is throwing an exception, look at what kind of object is stored there.
 
Back
Top Bottom