Re: removing sidHistory



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.

"Alex" <EF@xxxxxxxxxxxxx> wrote in message news:A97CCB44-28ED-4EA9-B1C0-BC8BC6AF7C8A@xxxxxxxxxxxxxxxx
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

"Steven Cheng [MSFT]" wrote:

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:
msdnmg@xxxxxxxxxxxxxx

==================================================
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.
--------------------
>From: <EF@xxxxxxxxxxxxx>
>Subject: removing sidHistory
>Date: Fri, 25 Apr 2008 00:08:49 +0800
>
>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
>
>
>
>
>




.



Relevant Pages

  • RE: removing sidHistory
    ... As for cleaning sidhistory, so far what I found is the following kb article ... #How To Use Visual Basic Script to Clear SidHistory ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: removing sidHistory
    ... As for cleaning sidhistory, so far what I found is the following kb article ... which provide the vbscript for cleaning sidhistory: ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: ADMT Errors
    ... I understand that you fail to migrate sidhistory ... when migrating users with ADMT. ... How to Troubleshoot Inter-Forest sIDHistory Migration with ADMTv2 ... Microsoft Online Partner Support ...
    (microsoft.public.windows.server.migration)
  • Re: Check if browser is NOT I.E.
    ... I have a web-based application I support ... I'm not arguing any browser is better than another. ... VBScript on a public website... ... would only rely on client side scripting for non-critical things, ...
    (microsoft.public.inetserver.asp.general)
  • RE: How to call queued component from VBScript?
    ... Microsoft MSDN Online Support Lead ... How to call queued component from VBScript? ...
    (microsoft.public.scripting.vbscript)