All you had to do was mention Pink Floyd!  :-)

This won't help much if you need to do it in C++, but I've attached a couple
scripts from "Managing Enterprise AD Services" for generating GUIDs and
encoding them in base64 using Perl:

For Windows:
Ch10-Listing14_Convert_Str_GUID_To_Bin.pl.txt

For UNIX:
Ch10-Listing15_UNIX_Create_GUIDs.pl.txt

As far as the Windows example, you can also use the Win32::Guidgen module
which is available now instead of shelling out to uuidgen.exe.

Robbie Allen
http://www.rallenhome.com/ (under construction)

-----Original Message-----
From: Sullivan, Kevin [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 30, 2003 9:57 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] how can i add the value of the SchemIDGUID when I
create a schemd object?


There are some modules in Perl that enable this. They were brought to my
attention by Robbie Allen, Robbie - "is there anybody out there... is there
any one at home..." (Pink Floyd)...

I can dig up the specifics but if someone else knows Perl well they may
already know it.

Kevin

-----Original Message-----
From: zhaohu [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 29, 2003 8:46 PM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir] how can i add the value of the SchemIDGUID when I
create a schemd object?

yeah, i wanna specify a value for schemaIDGUID in order to create extended
rights for some objects, and i get the Base64-encoded format value by the
utility uuidgen.exe.
then  how do you extend the schema using LDIF files? could you show me an
example, because i had failed to do that, so i have to program it by C++ ,
thanks very much~
----- Original Message ----- 
From: Fugleberg, David A 
To: [EMAIL PROTECTED] 
Sent: Friday, May 30, 2003 3:43 AM
Subject: RE: [ActiveDir] how can i add the value of the SchemIDGUID when I
create a schemd object?

I'm not the expert either, but I do have some experience with this.
Normally, like Rick said, GUIDs are simply assigned by the system upon
object creation.  SchemaIDGUID is kind of a special case, though - it's the
GUID of the classSchema or attributeSchema object itself.  If you ever want
to define some extended rights that apply to instances of your new class or
attribute, you'll need to know the SchemaIDGUID of the classSchema or
attributeSchema object in the forest.

Let's say you write a program that extends the schema, and it does NOT
specify the schemaIDGUID.  The system will generate one for you when the
program is run.  If you run it again in a different forest, those objects
will have a different value of schemaIDGUID in that forest.  On the other
hand, if your program DOES specify a value for schemaIDGUID, then it will
have that value in every forest where your extension is installed.  That
way, you can document what it should be, and can programatically create
extended rights for those objects in any of those forests.

The value must be in the Base64-encoded format.  There are a couple of ways
to generate a value to use:
1. Install the extension on a test forest WITHOUT specifying the
schemaIDGUID, copy the value that gets automatically generated, and put in
it your program for future use on other forests

OR

2. Use the utility uuidgen.exe and convert the output (format
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to Base64.

I have done this successfully using LDIF files to extend the schema, but
have not tried it programmatically, although I see no reason why it would
not work the same.

Robbie, Gil, if I've misrepresented something here please correct me !

Dave

 -----Original Message-----
From: zhaohu [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 7:50 PM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir] how can i add the value of the SchemIDGUID when I
create a schemd object?
Today i think that maybe the SchemaIDGUID can only accept Base64, so i
replaced the {BCE8B3C4-9A94-4C34-8E76-AA4A682CBA2C} with Base64
xLPovJSaNEyOdqpKaCy6LA== , but the program still failed:(
Maybe Rick Kingslan is right, i can't assign a GUID to an object when i
create the object, then what about modifying the Value of SchemaIDGUID after
i create the object? i will test it after i send this mail:) 
      
----- Original Message ----- 
From: Rick Kingslan 
To: [EMAIL PROTECTED] 
Sent: Wednesday, May 28, 2003 8:46 PM
Subject: RE: [ActiveDir] how can i add the value of the SchemIDGUID when I
create a schemd object?

I am FAR from the expert on this subject, but I do know a thing or two.
(Gil, where are you when we need you???  ;-)  )

The one thing that I see is that you're trying to force a GUID.  I don't
think that you can do this.  You can't assign a GUID to an object - it's
assigned when created.  You're assigning an OID, which is good - as long as
it is unique and created via, say OIDGEN.  

Everything else looks fine.  This probably explains why the program runs
without the statement in question, but won't when you have it in.  It's not
supposed to be there.

Anyone else know schema manipulation with C++?  ;-)

Rick Kingslan  MCSE, MCSA, MCT
Microsoft MVP - Active Directory
Associate Expert
Expert Zone - www.microsoft.com/windowsxp/expertzone
  




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of zhaohu
Sent: Wednesday, May 28, 2003 2:29 AM
To: [EMAIL PROTECTED]
this is some code in my program, i create the schema object it:

----------------------------------------------------------------
hr = piSchema->Create( L"classSchema", L"CN=TestClass", &piDisp );
   .
   .
   .    
    hr = piDisp->QueryInterface( IID_IADs, ( void** )&piIADsClass );
    if( SUCCEEDED( hr ) )
    {
     hr = piIADsClass->Put( L"objectClass", _variant_t( L"classSchema" ) );
     hr = piIADsClass->Put( L"lDAPDisplayName", _variant_t( L"TestClass" )
);
     hr = piIADsClass->Put( L"governsID", _variant_t(
L"1.3.6.1.4.1.1593.4.2.1.1.2.43" ) );
     hr = piIADsClass->Put( L"subClassOf", _variant_t( L"top" ) );
     hr = piIADsClass->Put( L"possSuperiors",_variant_t(
L"organizationalUnit") );
     hr = piIADsClass->Put(
L"schemaIDGUID",_variant_t(L"{BCE8B3C4-9A94-4C34-8E76-AA4A682CBA2C}"));
     hr = piIADsClass->PutEx(ADS_PROPERTY_APPEND, L"mayContain", varNames3);
     
     .
     .
     .
----------------------------------------------------------------------

but it failed when i run the program, then if i comment or delete  " hr =
piIADsClass->Put(
L"schemaIDGUID",_variant_t(L"{BCE8B3C4-9A94-4C34-8E76-AA4A682CBA2C}"));"  it
runs well, who could tell me what is the matter with my promgram, thanks
very very much:)

!#/usr/bin/perl
# -----------------------------------------------------------------------------
# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
# Copyright (C) 2002 by Addison-Wesley
# Script by Robbie Allen
# 
# You have a royalty-free right to use, modify, reproduce and distribute
# this script (and/or any modified version) in any way you find useful,
# provided that you agree that Addison-Wesley or Robbie Allen has no
# warranty, obligations or liability for the script. If you modify
# the script, you must retain this copyright notice.
# -----------------------------------------------------------------------------
use MIME::Base64;
use Win32::Lanman;

# Get the string GUID
my $str_guid = `uuidgen.exe`;
chomp $str_guid;

# Convert to a binary GUID
my $bin_guid = Win32::Lanman::StringToGuid($str_guid);

# Base64 encode binary GUID
my $b64_guid = encode_base64($bin_guid);

print "$b64_guid\n";
# -----------------------------------------------------------------------------
# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
# Copyright (C) 2002 by Addison-Wesley
# Script by Robbie Allen
# 
# You have a royalty-free right to use, modify, reproduce and distribute
# this script (and/or any modified version) in any way you find useful,
# provided that you agree that Addison-Wesley or Robbie Allen has no
# warranty, obligations or liability for the script. If you modify
# the script, you must retain this copyright notice.
# -----------------------------------------------------------------------------
use Data::UUID;

# Get a GUID object
my $guid = Data::UUID->new();

# Create a new binary GUID
my $bin_guid = $guid->create();

# Base64 encode
my $b64_guid = $guid->to_b64string($bin_guid);

print "$b64_guid\n";

Reply via email to