removing sidHistory

G

Guest

Hi All,

Have anyone tried to remove sidHistory using C#?

I keep getting the following error when I use the PutEx method.

System.Runtime.InteropServices.COMException was unhandled
Message="Unspecified error\r\n"
Source="Active Directory"
ErrorCode=-2147467259
StackTrace:
at ActiveDs.IADs.PutEx(Int32 lnControlCode, String bstrName, Object
vProp)


Thanks,
Alex
 
S

Steven Cheng [MSFT]

Hi Alex,

As for cleaning sidhistory, so far what I found is the following kb article
which provide the vbscript for cleaning sidhistory:

#How To Use Visual Basic Script to Clear SidHistory
http://support.microsoft.com/?id=295758

have you tried using VB.NET code which maybe easy to convert from vb. Or
you can consider keep the vbs script and use C# to programmtically invoke
cmd to execute the vbscript.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
A

Alex

Hi Steven,

Yup, I have seen that KBA before. I agree that it should be easier to
convert vbscript to VB.Net but since I am learning C# so I thought of doing
it in C#. Anyway, I have get it working.

Thanks,
Alex
 
W

Willy Denoyette [MVP]

Note that you should not translate VBScript samples to C# or any .NET
language for that matter), .NET offers a rich class library to be used from
managed code, these class libraries make it much easier to access AD objects
than it was ever possible from unmanaged code.
The .NET way to clear the SID-History looks something like this:

using(DirectoryEntry root = new DirectoryEntry(@"LDAP://RootDSE"))
{
string defCtx =
root.Properties["defaultNamingContext"][0].ToString();
using(DirectoryEntry re = new DirectoryEntry("LDAP://" +
defCtx))
{
PropertyValueCollection sidH =
re.Properties["sidHistory"];
if(sidH.Count > 0)
{
sidH.Clear();
re.CommitChanges();
}
}
}

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top