473,395 Members | 1,458 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,395 software developers and data experts.

DirectoryService Problem...

Hi can someone please tell me how I get the username only into a datagrid I
have created to show all the Active Directory Users! At the moment the only
thing I can get to appear in the datagrid is the AD path!

E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET

Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case, is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter = ("(&(objectCategory=person)(objectClass=user))" )
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection

results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub
Nov 19 '05 #1
3 1090
OK I think I might have resolved my own problem!

<%#Container.DataItem.GetDirectoryEntry().Name%>

However all my results have CN= on! Is there a way to trim this off in the
Inline code?

EG:

CN=Joe Bloggs

Thanks

"Tim::.." wrote:
Hi can someone please tell me how I get the username only into a datagrid I
have created to show all the Active Directory Users! At the moment the only
thing I can get to appear in the datagrid is the AD path!

E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET

Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case, is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter = ("(&(objectCategory=person)(objectClass=user))" )
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection

results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub

Nov 19 '05 #2
Hi Tim,

Will an inline Replace() work?

<%#Replace(Container.DataItem.GetDirectoryEntry(). Name,"CN=","") %>

It sounds like you're making good progress with that project.

Ken
Microsoft MVP [ASP.NET]
Toronto
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:BF**********************************@microsof t.com...
OK I think I might have resolved my own problem!

<%#Container.DataItem.GetDirectoryEntry().Name%>

However all my results have CN= on! Is there a way to trim this off in the
Inline code?

EG:

CN=Joe Bloggs

Thanks

"Tim::.." wrote:
Hi can someone please tell me how I get the username only into a datagrid
I
have created to show all the Active Directory Users! At the moment the
only
thing I can get to appear in the datagrid is the AD path!

E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET

Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case,
is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter =
("(&(objectCategory=person)(objectClass=user))" )
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection

results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub


Nov 19 '05 #3
That is exactly what I needed!
Thanks...

Funny how you forget simple things like that sometimes!

Cheers

"Ken Cox [Microsoft MVP]" wrote:
Hi Tim,

Will an inline Replace() work?

<%#Replace(Container.DataItem.GetDirectoryEntry(). Name,"CN=","") %>

It sounds like you're making good progress with that project.

Ken
Microsoft MVP [ASP.NET]
Toronto
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:BF**********************************@microsof t.com...
OK I think I might have resolved my own problem!

<%#Container.DataItem.GetDirectoryEntry().Name%>

However all my results have CN= on! Is there a way to trim this off in the
Inline code?

EG:

CN=Joe Bloggs

Thanks

"Tim::.." wrote:
Hi can someone please tell me how I get the username only into a datagrid
I
have created to show all the Active Directory Users! At the moment the
only
thing I can get to appear in the datagrid is the AD path!

E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET

Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case,
is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter =
("(&(objectCategory=person)(objectClass=user))" )
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection

results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub


Nov 19 '05 #4

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
0
by: Justin Rich | last post by:
I would like to find a way to use the data grid to hook in to the AD. Was looking at the choices for data sources and i didnt see a way to do it, but figured i would ask to see if i missed...
0
by: Tim::.. | last post by:
Can someone please help! I am trying to use DirectoryServices with a datagrid to show the different users in our AD and then have a button that will show the details of the selected user and...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.