msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Setting User Properties in Active Directory

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
You Big Dummy



Joined: 04 Oct 2007
Posts: 1

PostPosted: Mon Aug 14, 2006 2:17 pm    Post subject: Setting User Properties in Active Directory Reply with quote

I have been trying to set user's properties for AD accounts and have made it
pretty far. But now I have an error that I can't find an answer too. Here is
my code. The problem is that in my ModifyUserProperties Sub the Term
GetDirectoryEntry says Directory Entry cannot be indexed because it has no
default property. Does anyone have any idea as I am at a deadend.

Public Shared Function GetDirectoryEntry() As DirectoryEntry
Dim de As DirectoryEntry = New DirectoryEntry()
de.Path = "LDAP://ipaddress"
de.Username = "domain\username"
de.Password = "password"
return de
End Function
Public Sub ModifyUserProperties(ByVal displayname As String, ByVal
department As String, ByVal title As S)
Dim de As DirectoryEntry = GetDirectoryEntry()
Dim ds As DirectorySearcher = New DirectorySearcher(de)
ds.Filter =
"(&(objectCategory=Person)(objectClass=user)(displayName=" + displayname +
"))"
ds.SearchScope = SearchScope.Subtree
Dim results As SearchResult = ds.FindOne()
If Not results Is Nothing Then
Dim dey As DirectoryEntry = GetDirectoryEntry(results.Path)
problem is here
SetProperty(dey, "employee-id", EmplID.Text)
dey.CommitChanges()
dey.Close()
End If
de.Close()
End Sub
Public Shared Sub SetProperty(ByVal de As DirectoryEntry, ByVal PropertyName
As String, ByVal PropertyValue As String)
If Not PropertyValue Is Nothing Then
If de.Properties.Contains(PropertyName) Then
de.Properties(PropertyName)(0) = PropertyValue
Else
de.Properties(PropertyName).Add(PropertyValue)
End If
End If
End Sub

Archived from group: microsoft>public>vb>enterprise
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1325

PostPosted: Mon Aug 14, 2006 4:37 pm    Post subject: Re: Setting User Properties in Active Directory Reply with quote

"You Big Dummy" wrote in message@microsoft.com...
> I have been trying to set user's properties for AD accounts and have made
it
> pretty far. But now I have an error that I can't find an answer too. Here
is
> my code. The problem is that in my ModifyUserProperties Sub the Term
> GetDirectoryEntry says Directory Entry cannot be indexed because it has no
> default property. Does anyone have any idea as I am at a deadend.
>
> Public Shared Function GetDirectoryEntry() As DirectoryEntry
> Dim de As DirectoryEntry = New DirectoryEntry()


--
try asking in a group with "dotnet" in the name; this group is for VB 6.0
and earlier
VB.Net is Not.VB

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group