DirectoryServices

DirectoryServices

Post by Wayne Tayl » Mon, 08 Sep 2003 07:24:45


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.
 
 
 

DirectoryServices

Post by Herfried K » Mon, 08 Sep 2003 08:45:16

Hello,


"Wayne Taylor" < XXXX@XXXXX.COM > schrieb:
please.Thanks

C# -> VB .NET Converters:

http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/

http://www.yqcomputer.com/
-> "Octopus"
--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.yqcomputer.com/

 
 
 

DirectoryServices

Post by Fergus Coo » Mon, 08 Sep 2003 08:49:35

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
 
 
 

DirectoryServices

Post by Troy » Mon, 06 Jun 2005 16:13:09

hello,

I'm trying to write code using the directoryservices namespace that'll
update some AD attributes however the code seems to be failing. I'm hoping
somebody can have a look at it and offer feedback or probably post sample
code:

It's failing at the update attribute level.


Sub ModifyUser(ByRef temp() As String)
' CN=mjtest,OU=SL Users,DC=softlanding,DC=local
Dim AccountDN As String = "CN=" + temp(0) + ",OU=SL
Users,DC=domain,DC=local"
Console.WriteLine(AccountDN)
Try
Dim ent As New DirectoryEntry("LDAP://" + AccountDN)
ent.Properties("otherTelephone").Add( Add("(425) 523 1462")
Console.WriteLine(ent.Properties("sAMAccountName"))

'ent.Properties("title").Value = "Test Title"
ent.CommitChanges()
Catch Ex As Exception
Console.WriteLine(Ex.Message)
End Try




End Sub



End Module



Any help is appreciated.

thanks
 
 
 

DirectoryServices

Post by Bria » Sun, 17 May 2009 03:07:49

Hello,
I am using DirectoryService and directoryentry to authenicate users with the
Domain AD.....
My question is.. if the Domain Ad is not there.. how can i check agaist the
local cached credienals ?
Brian