473,325 Members | 2,870 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,325 software developers and data experts.

DirectoryServices

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.

Nov 20 '05 #1
2 7616
Hello,
"Wayne Taylor" <wt*@kryptos.co.uk> 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
Nov 20 '05 #2
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
Nov 20 '05 #3

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

Similar topics

0
by: kovac | last post by:
The System.directoryservices.dll has an error, and this error was described in http://support.microsoft.com/default.aspx?scid=kb;en-us;839424 At the moment we have Framework version v1.0.3705 and...
12
by: hykim | last post by:
Hello, everyone. according to MSDN, there is any constructor of System.DirectoryServices.SearchResultCollection Class. if I implement DirectorySearcher.FindAll() method by myself, then how can I...
1
by: Jason Gleason | last post by:
I am using the following method in a web service that utilizes the system.directoryservices namespace: public ArrayList GetAllAppPools(){ System.DirectoryServices.DirectoryEntry apppools = new...
1
by: Enosh Chang | last post by:
Hi all, I encounter some problem in DirectoryServices, could someone help me? private void InitLoginUser() { DirectoryEntry objEntry = new DirectoryEntry(); DirectorySearcher objSearcher =...
0
by: Chris Frohlich | last post by:
All, I've built an Employee Directory with ASP.NET app that queries Active Directory for users and builds links with the results. What I'm seeing is really intermittent failures to bind to the...
9
by: Günther Rühmann | last post by:
Hi, I´m not sure if i´m right int this group... My problem: I made a vb .net application that reads from AD via System.Directoryservices.Directoryentry. The appliocation enumerates group...
2
by: Kelvin | last post by:
Hello I am using web matrix develop a login page through Active Directory but I cannot figure out why it is giving me an error when importing system.directoryServices. Any help will do! thank ...
5
by: Keith Jakobs, MCP | last post by:
Hi All.... I'm having a HECK of a time connecting to Active Directory using VB in Visual Studio.NET 2003. Can anyone PLEASE help me? All I am trying to do is list the current members of our...
7
by: turbon | last post by:
Hello, I am writing code, which will copy webServices from one IIS 6.0 webserver to another and using DirentoryServices to achieve this purpose. And I have problems with authentication - I get an...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.