ADSI Invoke question... 
Author Message
 ADSI Invoke question...

I need to be able to get/set attributes of Users and Groups from the Active
Directory.  Do I need to Invoke a native Active Directory method to do this,
and if so which one.  I would like use the ActiveDs.IADsUser but what method
do I invoke it use it with System.DirectoryServices.DirectoryEntry?  Thanks
for your help.

Kirk



Mon, 22 Mar 2004 00:12:53 GMT  
 ADSI Invoke question...
If the thing you are trying to do is not a member on the DirectoryEntry
natively (like DeleteTree)
Then use myDirectoryEntry.Invoke("methodname", myParamArray);
-mike


Quote:
> I need to be able to get/set attributes of Users and Groups from the
Active
> Directory.  Do I need to Invoke a native Active Directory method to do
this,
> and if so which one.  I would like use the ActiveDs.IADsUser but what
method
> do I invoke it use it with System.DirectoryServices.DirectoryEntry?
Thanks
> for your help.

> Kirk



Mon, 22 Mar 2004 01:04:02 GMT  
 ADSI Invoke question...
To clarify, I am trying to get/set attributes like (FirstName, LastName,
PostalAddresses, TelephoneNumber...... etc) How can I do this, which method
do I Invoke?


Quote:
> If the thing you are trying to do is not a member on the DirectoryEntry
> natively (like DeleteTree)
> Then use myDirectoryEntry.Invoke("methodname", myParamArray);
> -mike



> > I need to be able to get/set attributes of Users and Groups from the
> Active
> > Directory.  Do I need to Invoke a native Active Directory method to do
> this,
> > and if so which one.  I would like use the ActiveDs.IADsUser but what
> method
> > do I invoke it use it with System.DirectoryServices.DirectoryEntry?
> Thanks
> > for your help.

> > Kirk



Mon, 22 Mar 2004 01:19:59 GMT  
 ADSI Invoke question...
You don't need to call native methods to get/set properties, just specify the property as indexer.

Try this:
....
string UserPath = "LDAP://nnnnnn/CN=userName,CN=Users,DC=...,DC=.....,DC=....";
DirectoryEntry userEntry = new DirectoryEntry(UserPath, strUsername, strPassword, AuthenticationTypes.Secure );
//
userEntry .Properties["DisplayName"] = .... ;
or
.... = userEntry .Properties["xxxxxx"];

Willy.

Quote:

> To clarify, I am trying to get/set attributes like (FirstName, LastName,
> PostalAddresses, TelephoneNumber...... etc) How can I do this, which method
> do I Invoke?



> > If the thing you are trying to do is not a member on the DirectoryEntry
> > natively (like DeleteTree)
> > Then use myDirectoryEntry.Invoke("methodname", myParamArray);
> > -mike



> > > I need to be able to get/set attributes of Users and Groups from the
> > Active
> > > Directory.  Do I need to Invoke a native Active Directory method to do
> > this,
> > > and if so which one.  I would like use the ActiveDs.IADsUser but what
> > method
> > > do I invoke it use it with System.DirectoryServices.DirectoryEntry?
> > Thanks
> > > for your help.

> > > Kirk



Mon, 22 Mar 2004 03:33:06 GMT  
 ADSI Invoke question...
Willy,

    I thought I didn't need to call native methods to get/set properties,
but after I Enumerated through all of the PropertyNames and I only got 23
properties and I should be getting way more.  So how come I can not get/set
properties like "EmailAddress, FirstName,LastName,PostalCodes etc..." ???

    Just so you know this these are the only properties I can access:

"Ra{*filter*}issions, UserFlags, MaxStorage, PasswordAge, PasswordExpired,
LoginHours, FullName, Description, BadPasswordAttempts, HomeDirectory,
LoginScript, Profile, HomeDirDrive, Parameters, PrimaryGroupID,
MinPasswordLength, MaxPasswordAge, MinPasswordAge, PasswordHistoryLength,
AutoUnlockInterval, LockoutObservationInterval, MaxBadPasswordsAllowed,
objectSid"

Thanks.....

Kirk


Quote:
> You don't need to call native methods to get/set properties, just specify

the property as indexer.
Quote:

> Try this:
> ....
> string UserPath =

"LDAP://nnnnnn/CN=userName,CN=Users,DC=...,DC=.....,DC=....";
Quote:
> DirectoryEntry userEntry = new DirectoryEntry(UserPath, strUsername,

strPassword, AuthenticationTypes.Secure );
Quote:
> //
> userEntry .Properties["DisplayName"] = .... ;
> or
> .... = userEntry .Properties["xxxxxx"];

> Willy.




Quote:
> > To clarify, I am trying to get/set attributes like (FirstName, LastName,
> > PostalAddresses, TelephoneNumber...... etc) How can I do this, which
method
> > do I Invoke?



> > > If the thing you are trying to do is not a member on the
DirectoryEntry
> > > natively (like DeleteTree)
> > > Then use myDirectoryEntry.Invoke("methodname", myParamArray);
> > > -mike



> > > > I need to be able to get/set attributes of Users and Groups from the
> > > Active
> > > > Directory.  Do I need to Invoke a native Active Directory method to
do
> > > this,
> > > > and if so which one.  I would like use the ActiveDs.IADsUser but
what
> > > method
> > > > do I invoke it use it with System.DirectoryServices.DirectoryEntry?
> > > Thanks
> > > > for your help.

> > > > Kirk



Mon, 22 Mar 2004 04:40:20 GMT  
 ADSI Invoke question...
     I thought I didn't need to call native methods to get/set properties,
but after I Enumerated through all of the PropertyNames and I only got 23
properties and I should be getting way more.  So how come I can not get/set
properties like "EmailAddress, FirstName,LastName,PostalCodes etc..." ???

    Just so you know this these are the only properties I can access:

"Ra{*filter*}issions, UserFlags, MaxStorage, PasswordAge, PasswordExpired,
LoginHours, FullName, Description, BadPasswordAttempts, HomeDirectory,
LoginScript, Profile, HomeDirDrive, Parameters, PrimaryGroupID,
MinPasswordLength, MaxPasswordAge, MinPasswordAge, PasswordHistoryLength,
AutoUnlockInterval, LockoutObservationInterval, MaxBadPasswordsAllowed,
objectSid"

Thanks.....

Kirk


Quote:
> You don't need to call native methods to get/set properties, just specify

the property as indexer.
Quote:

> Try this:
> ....
> string UserPath =

"LDAP://nnnnnn/CN=userName,CN=Users,DC=...,DC=.....,DC=....";
Quote:
> DirectoryEntry userEntry = new DirectoryEntry(UserPath, strUsername,

strPassword, AuthenticationTypes.Secure );
Quote:
> //
> userEntry .Properties["DisplayName"] = .... ;
> or
> .... = userEntry .Properties["xxxxxx"];

> Willy.




Quote:
> > To clarify, I am trying to get/set attributes like (FirstName, LastName,
> > PostalAddresses, TelephoneNumber...... etc) How can I do this, which
method
> > do I Invoke?



> > > If the thing you are trying to do is not a member on the
DirectoryEntry
> > > natively (like DeleteTree)
> > > Then use myDirectoryEntry.Invoke("methodname", myParamArray);
> > > -mike



> > > > I need to be able to get/set attributes of Users and Groups from the
> > > Active
> > > > Directory.  Do I need to Invoke a native Active Directory method to
do
> > > this,
> > > > and if so which one.  I would like use the ActiveDs.IADsUser but
what
> > > method
> > > > do I invoke it use it with System.DirectoryServices.DirectoryEntry?
> > > Thanks
> > > > for your help.

> > > > Kirk



Mon, 22 Mar 2004 07:24:58 GMT  
 ADSI Invoke question...

Quote:

> Willy,

>     I thought I didn't need to call native methods to get/set properties,
> but after I Enumerated through all of the PropertyNames and I only got 23
> properties and I should be getting way more.  So how come I can not get/set
> properties like "EmailAddress, FirstName,LastName,PostalCodes etc..." ???

>     Just so you know this these are the only properties I can access:

> "Ra{*filter*}issions, UserFlags, MaxStorage, PasswordAge, PasswordExpired,
> LoginHours, FullName, Description, BadPasswordAttempts, HomeDirectory,
> LoginScript, Profile, HomeDirDrive, Parameters, PrimaryGroupID,
> MinPasswordLength, MaxPasswordAge, MinPasswordAge, PasswordHistoryLength,
> AutoUnlockInterval, LockoutObservationInterval, MaxBadPasswordsAllowed,
> objectSid"

No those are not created by default , you will need to create them when creating a (or updating an existing) user, like:


objNewEntry.Properties["givenName"].Add("Kirk");

You should take care to use the AD and not the ADSI property names (see the SDK docs for the mappings):

ADSI name = AD Name
EmailAddress = mail
FirstName = givenName
FullName = displayName
LastName = sn
PostalCodes = postalcode
....

Hope this helps.

Willy.



Mon, 22 Mar 2004 16:59:45 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. ADSI Question

2. Invoking a method of the class CComDispatchDriver(Invoke N)

3. P/invoke FindFirstFile / FindNextFile question

4. Question about invoking ANSI C and POSIX.2 C

5. Question on invoking jvm in a DLL

6. ADSI How to enable user?

7. ADSI:IIS properties, who to enum

8. How to use ADSI methods in C#?

9. Odd ADSI Problem

10. No one to help me? ADSI Problem

11. ADSI

12. ADSI / group policy ?

 

 
Powered by phpBB® Forum Software