Click here to Skip to main content
16,015,072 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Selecting a dropdownlist value in gridview edit mode Pin
eyeseetee9-Jul-08 0:38
eyeseetee9-Jul-08 0:38 
QuestionHow to make query string as read only. Pin
BalasubramanianK8-Jul-08 21:40
BalasubramanianK8-Jul-08 21:40 
AnswerRe: How to make query string as read only. Pin
eyeseetee8-Jul-08 22:22
eyeseetee8-Jul-08 22:22 
GeneralRe: How to make query string as read only. Pin
BalasubramanianK8-Jul-08 22:35
BalasubramanianK8-Jul-08 22:35 
GeneralRe: How to make query string as read only. Pin
BalasubramanianK8-Jul-08 22:51
BalasubramanianK8-Jul-08 22:51 
GeneralRe: How to make query string as read only. Pin
eyeseetee8-Jul-08 22:54
eyeseetee8-Jul-08 22:54 
AnswerRe: How to make query string as read only. Pin
N a v a n e e t h8-Jul-08 23:05
N a v a n e e t h8-Jul-08 23:05 
Questionproblem in Active director multiple domain for search user Pin
Piyush Vardhan Singh8-Jul-08 21:36
Piyush Vardhan Singh8-Jul-08 21:36 
i am working on Active director multiple domain for search user.but Its produced Error:- There is no such object on the server. -2147016656
Please Help me.


Code:-

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FindUser("dev\t", True)
End Sub
Public Function FindUser(ByVal principalname As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim searchRoot As DirectoryEntry
Dim searcher As DirectorySearcher
Dim name() As String

Dim ncName As String

name = principalname.Split("\")
If name.Length <> 2 Then
Throw New ArgumentException("principalname is not in the correct format", principalname)
End If
ncName = ResolveNetBiosNameToDN(name(0))
searchRoot = GetDirectoryEnTry(ncName, useGC)
searcher = New DirectorySearcher(searchRoot, String.Format("(&(objectCategory=person)?(objectClass=user)? (sAMAccountName={0}))", name(1)), New String() {"distinguishedName"}, SearchScope.Subtree)
Try
Return searcher.FindOne().GetDirectoryEntry()

Catch ex As NullReferenceException
Throw New ArgumentException("The given username was not found", "principalname", ex)
End Try
Catch ex As Exception

End Try
End Function
Private Function ResolveNetBiosNameToDN(ByVal netbiosName As String) As String
Try
Dim authenticationType As New System.DirectoryServices.AuthenticationTypes
If ConfigurationManager.AppSettings("AD_UseSecureConnection").ToUpper.Trim.Equals("TRUE") Then
authenticationType = AuthenticationTypes.Secure
Else
authenticationType = AuthenticationTypes.None
End If
Dim rootDSE As New DirectoryEntry(ConfigurationManager.AppSettings("AD_IP").Trim, ConfigurationManager.AppSettings("AD_UserName").Trim, ConfigurationManager.AppSettings("AD_Password").Trim, authenticationType)
' Dim configurationNamingContext As String = CType(rootDSE.Properties("configurationNamingContext").Value, String)
Dim defaultNamingContext As String = CType(rootDSE.Properties("distinguishedName").Value, String)
'defaultNamingContext = defaultNamingContext.Split(",")(0)
' Dim Str As String =
Return CType(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, defaultNamingContext)).Properties("nCName").Value, String)
' Return DirectCast(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, DirectCast(configurationNamingContext.Properties("distinguishedName").Value, String))).Properties("nCName").Value, String)
'Dim ss As String = "sada"
Catch ex As System.Runtime.InteropServices.COMException
If CInt(ex.ErrorCode) = 2147950640 Then
Throw New ArgumentException("The given netbios name was invalid", "netbiosName", ex)
Else
Throw
End If
Catch ex As Exception
' return (string) GetDirectoryEntry(string.Format("CN={0}, CN=Partitions, {1}", netbiosName, (string) ConfigurationNamingContext.Properties["distinguishedName"].Value)).Properties["nCName"].Value;
End Try
End Function
Public Function GetDirectoryEnTry(ByVal distinguishedName As String) As DirectoryEntry

Return GetDirectoryEnTry(distinguishedName, False)

End Function

Public Function GetDirectoryEntry(ByVal distinguishedName As String, ByVal useGC As Boolean) As DirectoryEntry
Try

Dim path As String
path = IIf((useGC), "GC://", "LDAP://")
Dim _server As String = "dev.eventure.biz"
If _server IsNot Nothing Then
path += _server
End If
If (Not path.EndsWith("/")) AndAlso (distinguishedName <> "") Then
path += "/"
End If
path += distinguishedName
If path.EndsWith("//") Then
path = path.Remove(path.Length - 2, 2)
End If
Return New DirectoryEntry(path, "dev\adadmin", "password_1234", AuthenticationTypes.Secure)

Catch ex As Exception

End Try
End Function




Thanks

Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com



QuestionHow to sort string-based numeric data?? Pin
Nada Adel8-Jul-08 21:10
Nada Adel8-Jul-08 21:10 
AnswerRe: How to sort string-based numeric data?? Pin
eyeseetee8-Jul-08 21:25
eyeseetee8-Jul-08 21:25 
GeneralRe: How to sort string-based numeric data?? Pin
Nada Adel8-Jul-08 21:30
Nada Adel8-Jul-08 21:30 
GeneralRe: How to sort string-based numeric data?? Pin
eyeseetee8-Jul-08 21:39
eyeseetee8-Jul-08 21:39 
GeneralRe: How to sort string-based numeric data?? Pin
eyeseetee8-Jul-08 22:25
eyeseetee8-Jul-08 22:25 
AnswerRe: How to sort string-based numeric data?? Pin
Sherin Iranimose8-Jul-08 21:28
Sherin Iranimose8-Jul-08 21:28 
GeneralRe: How to sort string-based numeric data?? Pin
Nada Adel8-Jul-08 21:48
Nada Adel8-Jul-08 21:48 
GeneralRe: How to sort string-based numeric data?? Pin
Ashfield8-Jul-08 22:31
Ashfield8-Jul-08 22:31 
GeneralRe: How to sort string-based numeric data?? Pin
Sherin Iranimose8-Jul-08 22:35
Sherin Iranimose8-Jul-08 22:35 
GeneralRe: How to sort string-based numeric data?? Pin
Sherin Iranimose8-Jul-08 22:34
Sherin Iranimose8-Jul-08 22:34 
GeneralRe: How to sort string-based numeric data?? Pin
Nada Adel9-Jul-08 0:40
Nada Adel9-Jul-08 0:40 
GeneralRe: How to sort string-based numeric data?? Pin
Ashfield9-Jul-08 9:37
Ashfield9-Jul-08 9:37 
GeneralRe: How to sort string-based numeric data?? Pin
N a v a n e e t h8-Jul-08 22:40
N a v a n e e t h8-Jul-08 22:40 
QuestionHow to bind a gridview from a popup window?? Pin
Nada Adel8-Jul-08 20:55
Nada Adel8-Jul-08 20:55 
AnswerRe: How to bind a gridview from a popup window?? Pin
eyeseetee8-Jul-08 21:35
eyeseetee8-Jul-08 21:35 
GeneralRe: How to bind a gridview from a popup window?? Pin
Nada Adel8-Jul-08 21:46
Nada Adel8-Jul-08 21:46 
GeneralRe: How to bind a gridview from a popup window?? Pin
eyeseetee8-Jul-08 22:26
eyeseetee8-Jul-08 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.