I have a function that is in a vbs file.
I want a 1:1 copy of the functionality using COM, but want it in a C# console app. Is this possible?
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
set dso=GetObject("LDAP:")
Set objOU = GetObject("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=Customers")
objGroup.Put "sAMAccountName", "customers"
objGroup.Put "groupType", ADS_GROUP_TYPE_UNIVERSAL_GROUP
objGroup.SetInfo
Thanks in advance.
Yes, it is possible, but you would need to reference the COM object in the C# project, let VS.NET generate the RCW (runtime callable wrapper) and then call the methods a C# object. It won’t be a 1:1 correlation since some of the object initialization will be slightly different, but it will be close.
On a side note, if you are simply trying to do Active Directory administration, there are better built in objects in C# that could be used.