PC Review


Reply
Thread Tools Rate Thread

DirectoryServices

 
 
Wayne Taylor
Guest
Posts: n/a
 
      6th Sep 2003
Hello all,

I'm getting there.... I now have my user object created and I can set most
of the properties that I want to... the problem now is when I'm creating my
user object the user account is disabled by default. I have been looking at
C# examples form the MSDN site... I've never written anything in flavour of
C so it's difficult for me to read code and understand what it's doing...
this is the example code:

[C#]
DirectoryEntry usr =
new DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val & ~ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();The following code example shows how to disable a user
account.

[C#]
DirectoryEntry usr =
new DirectoryEntry("LDAP://CN=Old User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();Can anyone convert this into VB.NET code, please.Thanks
in advance, Wayne..Microsoft ...... why don't you produce all examples in
both languages? You seem to for most not all, I don't understand... I see
this as a sign the VB will in time loose out.


histrory
Hello all

I'm trying to write a liitle application to add users to AD, when I'm trying
to add a user and a group (example code from the SDK)..... I get the
following error:

A constraint violation occurred.

I think it may be something to do with access writes, I'm not sure... I'm
logged in as system admin on my lab network.... I'm off to try and sort this
out as I need to have a working app by Monday!

No pressure.... :-)

Thanks in advance, Wayne.



 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      7th Sep 2003
Hello,


"Wayne Taylor" <(E-Mail Removed)> schrieb:
> [C#]
> DirectoryEntry usr =
> new DirectoryEntry("LDAP://CN=Old User,CN=users,DC=fabrikam,DC=com");
> int val = (int) usr.Properties["userAccountControl"].Value;
> usr.Properties["userAccountControl"].Value = val | ADS_UF_ACCOUNTDISABLE;
> usr.CommitChanges();Can anyone convert this into VB.NET code,

please.Thanks
> in advance, Wayne..Microsoft ...... why don't you produce all examples in


C# -> VB .NET Converters:

http://www.kamalpatel.net/ConvertCSharp2VB.aspx
http://csharpconverter.claritycon.com/Default.aspx
http://www.ragingsmurf.com/vbcsharpconverter.aspx
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

http://www.remotesoft.com/
-> "Octopus"
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      7th Sep 2003
Hi Wayne,

[VB]
Const ADS_UF_ACCOUNTDISABLE = &H2
Dim usr As DirectoryEntry = New DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com")
Dim val As Integer = CInt (usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val And Not ADS_UF_ACCOUNTDISABLE
usr.CommitChanges

[VB]
Const ADS_UF_ACCOUNTDISABLE = &H2
Dim usr As DirectoryEntry = New DirectoryEntry("LDAP://CN=Old User,CN=users,DC=fabrikam,DC=com")
Dim val As Integer = CInt (usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or ADS_UF_ACCOUNTDISABLE
usr.CommitChanges

Regards,
Fergus


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: DirectoryServices Marc Scheuner Microsoft C# .NET 0 27th Aug 2008 05:43 AM
RE: DirectoryServices rihadd Microsoft C# .NET 0 21st Aug 2008 05:34 PM
IIS And DirectoryServices Ram Microsoft VB .NET 0 9th Jan 2005 11:58 AM
IIS And DirectoryServices Ram Microsoft C# .NET 3 6th Jan 2005 11:22 AM
DirectoryServices or not.. Tamir Khason Microsoft C# .NET 4 17th Dec 2004 11:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.