473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using serviceConnectionPoints

Does anyone have any experience using SCPs (serviceConnectionPoints) in
C#? Specifically, I'm trying to use an SCP to locate a service on a
server, once the service has created the SCP.

I've found some documentation on MSDN (at:
http://msdn2.microsoft.com/en-us/library/ms676925.aspx) but it's all
Win32 stuff which doesn't help me as I started with .NET.

Dec 26 '06 #1
5 3101
"ssg31415926" <ne**********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Does anyone have any experience using SCPs (serviceConnectionPoints) in
C#? Specifically, I'm trying to use an SCP to locate a service on a
server, once the service has created the SCP.

I've found some documentation on MSDN (at:
http://msdn2.microsoft.com/en-us/library/ms676925.aspx) but it's all
Win32 stuff which doesn't help me as I started with .NET.

It's not Win32 stuff, it's C++ code that calls ActiveDirectory COM API's. The same can be
achieved by using System.DirectoryServices in .NET. Check MSDN for samples using C# to
access the AD's Global Catalog (GC).

Willy.

Dec 26 '06 #2
Thanks for the reply. Win32, COM+, it's all Greek to me! I guess, in
a couple of years, there might be a "Win32/COM+ for .NET Programmers"
but in the meantime...

Anyway, I've put this together and am posting it here in case it's of
use to anyone else:

using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;

namespace LocateAServiceUsingAnSCP
{
class Program
{
static void Main(string[] args)
{
string gcPath;
gcPath = GetGlobalCatalogNC();
using (DirectoryEntry gcRoot = new DirectoryEntry("GC://" +
gcPath))
using (DirectorySearcher ds = new DirectorySearcher())
{
//Search the global catalog for objects with a
//keyword which identifies the ADAM instance
ds.SearchRoot = gcRoot;
ds.SearchScope = SearchScope.Subtree;
ds.PageSize = 1000;
//looking for an ADAM instance from the
//Microsoft ADAM Step-by-Step Guide
ds.Filter = "(keywords=partition:O=Microsoft,C=US)";
using (SearchResultCollection src = ds.FindAll())
{
if (src.Count == 0)
{
Console.WriteLine("No results found - " +
"press <ENTERto close this window...");
Console.ReadLine();
return;
}
foreach (SearchResult sr in src)
{
//bind to the Global Catalog entry for the SCP
using (DirectoryEntry gcDirEntry =
sr.GetDirectoryEntry())
{
Console.WriteLine("Global Catalog Entry:
{0}",
gcDirEntry.Path);
string distinguishedName =

gcDirEntry.Properties["distinguishedName"].Value.ToString();

//using the distinguishedName from the GC
entry,
//bind to the SCP object
using (DirectoryEntry ncDirEntry =
new DirectoryEntry("LDAP://" +
distinguishedName))
{
string serviceClassName =

ncDirEntry.Properties["serviceClassName"].Value.ToString();
string serviceDNSName =
ncDirEntry.Properties["serviceDNSName"].Value.ToString();
string serviceDNSNameType =
ncDirEntry.Properties["serviceDNSNameType"].Value.ToString();
object[] objects =

(object[])ncDirEntry.Properties["serviceBindingInformation"].Value;
string[] serviceBindingInformation =
new string[objects.Length];

objects.CopyTo(serviceBindingInformation, 0);

Console.WriteLine("serviceClassName :
{0}",
serviceClassName);
Console.WriteLine("serviceDNSName :
{0}",
serviceDNSName);
Console.WriteLine("serviceDNSNameType:
{0}",
serviceDNSNameType);
foreach (string serviceBindingItem in
serviceBindingInformation)
{

Console.WriteLine("serviceBindingInformation: {0}",
serviceBindingItem);
}
}
}
}
Console.WriteLine("Press <ENTERto close this
window...");
Console.ReadLine();
}
}

}

private static string GetGlobalCatalogNC()
{
string gcPath;
using (DirectoryEntry rootDSE = new
DirectoryEntry("LDAP://RootDSE"))
{
gcPath =
rootDSE.Properties["rootDomainNamingContext"].Value.ToString();
}
return gcPath;
}
}
}

Although it's knocked together to test the concept, rather than written
to be production code, I'd still appreciate any comments as to the way
I've done things.

Willy Denoyette [MVP] wrote:
"ssg31415926" <ne**********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Does anyone have any experience using SCPs (serviceConnectionPoints) in
C#? Specifically, I'm trying to use an SCP to locate a service on a
server, once the service has created the SCP.

I've found some documentation on MSDN (at:
http://msdn2.microsoft.com/en-us/library/ms676925.aspx) but it's all
Win32 stuff which doesn't help me as I started with .NET.


It's not Win32 stuff, it's C++ code that calls ActiveDirectory COM API's. The same can be
achieved by using System.DirectoryServices in .NET. Check MSDN for samples using C# to
access the AD's Global Catalog (GC).

Willy.
Dec 26 '06 #3
If you've got a minute, how can I tell what is COM+ and what isn't?
E.g. one of the MSDN SCP pages refers to using DnsQuery:
http://msdn2.microsoft.com/en-us/library/ms682016.aspx Is this COM+?
Is there somewhere I can look to find out how to use it in my C# code?

Regards

SSG

ssg31415926 wrote:
Thanks for the reply. Win32, COM+, it's all Greek to me! I guess, in
a couple of years, there might be a "Win32/COM+ for .NET Programmers"
but in the meantime...

Anyway, I've put this together and am posting it here in case it's of
use to anyone else:

using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;

namespace LocateAServiceUsingAnSCP
{
class Program
{
static void Main(string[] args)
{
string gcPath;
gcPath = GetGlobalCatalogNC();
using (DirectoryEntry gcRoot = new DirectoryEntry("GC://" +
gcPath))
using (DirectorySearcher ds = new DirectorySearcher())
{
//Search the global catalog for objects with a
//keyword which identifies the ADAM instance
ds.SearchRoot = gcRoot;
ds.SearchScope = SearchScope.Subtree;
ds.PageSize = 1000;
//looking for an ADAM instance from the
//Microsoft ADAM Step-by-Step Guide
ds.Filter = "(keywords=partition:O=Microsoft,C=US)";
using (SearchResultCollection src = ds.FindAll())
{
if (src.Count == 0)
{
Console.WriteLine("No results found - " +
"press <ENTERto close this window...");
Console.ReadLine();
return;
}
foreach (SearchResult sr in src)
{
//bind to the Global Catalog entry for the SCP
using (DirectoryEntry gcDirEntry =
sr.GetDirectoryEntry())
{
Console.WriteLine("Global Catalog Entry:
{0}",
gcDirEntry.Path);
string distinguishedName =

gcDirEntry.Properties["distinguishedName"].Value.ToString();

//using the distinguishedName from the GC
entry,
//bind to the SCP object
using (DirectoryEntry ncDirEntry =
new DirectoryEntry("LDAP://" +
distinguishedName))
{
string serviceClassName =

ncDirEntry.Properties["serviceClassName"].Value.ToString();
string serviceDNSName =
ncDirEntry.Properties["serviceDNSName"].Value.ToString();
string serviceDNSNameType =
ncDirEntry.Properties["serviceDNSNameType"].Value.ToString();
object[] objects =

(object[])ncDirEntry.Properties["serviceBindingInformation"].Value;
string[] serviceBindingInformation =
new string[objects.Length];

objects.CopyTo(serviceBindingInformation, 0);

Console.WriteLine("serviceClassName :
{0}",
serviceClassName);
Console.WriteLine("serviceDNSName :
{0}",
serviceDNSName);
Console.WriteLine("serviceDNSNameType:
{0}",
serviceDNSNameType);
foreach (string serviceBindingItem in
serviceBindingInformation)
{

Console.WriteLine("serviceBindingInformation: {0}",
serviceBindingItem);
}
}
}
}
Console.WriteLine("Press <ENTERto close this
window...");
Console.ReadLine();
}
}

}

private static string GetGlobalCatalogNC()
{
string gcPath;
using (DirectoryEntry rootDSE = new
DirectoryEntry("LDAP://RootDSE"))
{
gcPath =
rootDSE.Properties["rootDomainNamingContext"].Value.ToString();
}
return gcPath;
}
}
}

Although it's knocked together to test the concept, rather than written
to be production code, I'd still appreciate any comments as to the way
I've done things.

Willy Denoyette [MVP] wrote:
"ssg31415926" <ne**********@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
Does anyone have any experience using SCPs (serviceConnectionPoints) in
C#? Specifically, I'm trying to use an SCP to locate a service on a
server, once the service has created the SCP.
>
I've found some documentation on MSDN (at:
http://msdn2.microsoft.com/en-us/library/ms676925.aspx) but it's all
Win32 stuff which doesn't help me as I started with .NET.
>

It's not Win32 stuff, it's C++ code that calls ActiveDirectory COM API's. The same can be
achieved by using System.DirectoryServices in .NET. Check MSDN for samples using C# to
access the AD's Global Catalog (GC).

Willy.
Dec 26 '06 #4
"ssg31415926" <ne**********@gmail.comwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
If you've got a minute, how can I tell what is COM+ and what isn't?
E.g. one of the MSDN SCP pages refers to using DnsQuery:
http://msdn2.microsoft.com/en-us/library/ms682016.aspx Is this COM+?
Is there somewhere I can look to find out how to use it in my C# code?

Regards
Note that I didn't say COM+, I said COM.
The Active Directory access provider is implemented as a COM server, and exposed to the
"clients" as a set of COM interfaces called the "Active Directory Service Interfaces" (ADSI)
, one of the interfaces is IDirectoryObject another one is IDirectorySearch. The clients can
be implemented using native C++ or automation- compliant language clients like VB, VBScript,
managed code can use the the interfaces by means of the wrapper classes implemented by the
System.DirectoryServices classes.
Start here for more detailed info:
<http://msdn2.microsoft.com/en-us/library/aa746434.aspx>
..NET V2 also contains a lower level wrapper API set, accessible through the
System.DirectoryServices.Protocols namespace classes, these classes wrap the LDAP protocol
"C style" API set , which makes it possible to access the LDAP store from managed code
without passing through the ADSI provider interface.

Willy.

Dec 26 '06 #5
Thanks for your reply... looks like I've got a lot of reading ahead of
me!

SSG

Willy Denoyette [MVP] wrote:
"ssg31415926" <ne**********@gmail.comwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
If you've got a minute, how can I tell what is COM+ and what isn't?
E.g. one of the MSDN SCP pages refers to using DnsQuery:
http://msdn2.microsoft.com/en-us/library/ms682016.aspx Is this COM+?
Is there somewhere I can look to find out how to use it in my C# code?

Regards

Note that I didn't say COM+, I said COM.
The Active Directory access provider is implemented as a COM server, and exposed to the
"clients" as a set of COM interfaces called the "Active Directory Service Interfaces" (ADSI)
, one of the interfaces is IDirectoryObject another one is IDirectorySearch. The clients can
be implemented using native C++ or automation- compliant language clients like VB, VBScript,
managed code can use the the interfaces by means of the wrapper classes implemented by the
System.DirectoryServices classes.
Start here for more detailed info:
<http://msdn2.microsoft.com/en-us/library/aa746434.aspx>
.NET V2 also contains a lower level wrapper API set, accessible through the
System.DirectoryServices.Protocols namespace classes, these classes wrap the LDAP protocol
"C style" API set , which makes it possible to access the LDAP store from managed code
without passing through the ADSI provider interface.

Willy.
Dec 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using...
1
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
17
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
8
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
14
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
12
by: Calum Grant | last post by:
In older C++ computer books, you'll often see using namespace std; even in my 1996 copy of Stroustrup. Nowadays, it seems to be considered better to qualify names to make it clearer what...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.