ADAM / ADSI User Creation

Hi

I Was looking for some assistance with creation of a GroupOfNames class user that is created within ADAM of Active Directory.

I Have the following but it errors out and I think it has to do with the ADAM part of this need. Any assistance would be great.

This is what I have that is NOT working and was looking where to go from here.

$dom=[ADSI]“LDAP://OU=Users,OU=dev,OU=tdev,dc=acme,dc=com”
$obj = $dom.Create(‘GroupOfNames’, ‘CN=ASmith’)
$obj.SetInfo()

What errors do you receive when you run that code?

Hi
Thank you for responding. The following is the error. The GroupOfNames is a class that I need to create this in.

Exception calling “SetInfo” with “0” argument(s): "The requested operation did

not satisfy one or more constraints associated with the class of the object.

"

At line:1 char:1

  • $obj.SetInfo()

  • 
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    
      + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

According to http://msdn.microsoft.com/en-ca/library/cc221862.aspx , it looks like this class must contain a “member” attribute. You would need to populate this attribute before calling SetInfo().

I thought that this line represented that?

$obj = $dom.Create(‘GroupOfNames’, ‘CN=ASmith’)

Nope. In that line, you’re creating a GroupOfNames object that is itself called ‘ASmith’, rather than GroupOfNames object that contains ASmith as a member.

Aaaah so how would you create a user in ADAM within an ou like the following. the view I am representing is within adsiedit and is currently how we add a user of this type.

name class Distingguishedname

cn=fdoe groupofnames OU=Users,OU=dev,OU=tdev,dc=acme,dc=com

Well, a user and a groupOfNames are different things. If you want to create a groupOfNames object, you’re already on the right track, but it needs to contain at least one member. Something along these lines:

$ou = [ADSI]'LDAP://OU=Users,OU=dev,OU=tdev,dc=acme,dc=com'
$obj = $ou.Create('GroupOfNames', 'CN=fdoe')
$obj.member = 'CN=ASmith,OU=Users,OU=dev,OU=tdev,dc=acme,dc=com'
$obj.SetInfo()

I don’t know if that code will work as-is; I can’t test it at the moment. Working with ADSI via PowerShell can be a bit of a headache.

Thank you very much.
I am in no way even close to being a programmer and sometimes find it very difficult to bridge the programming terms / process with being a system admin.
I will try it out and respond back. This is a ldap connection for Teradata users and up to now it is a manual process. I want to script it so I can hand it off to our access control team.

Thanks again.