Login Active Directory

zhaozj2021-02-16  41

'********************************************************** *********************************************************** ** '// Start Date: May 21, 2002' // End Date: May 2002 '********************************* *********************************************************** ************************* OPTION EXPLICIT ON 'OPTION STRICT ON' // *********************** *********************************************************** ****************************************** Imports system.data.sqlclient

'// ******************************************************** *********************************************************** ** '// begin defined namespace' // begin Defined Class

Namespace sunerp.commclass.userlogin

Public Class ActiveDslogin

'// defined function loginactiveds' // function descriptoin' // This function is verified by the user, using the LDAP transfer user's certificate, '// use the iadsopendsObject and Iads interface of the ActiveDS object to connect Active Directory,' // Use Parameters activeds .__ midl ___ midl_itf_ads_0000_0018.ads_secure_authentication '// Force Certificate Binding User. '// This function does not have a parameters, with the attribute of class ActiveDSlogin, the ADUSERNAME (User Name), the' // ADUSERPWD (User Password), and AduserDeptval

'// begin define function loginactiveds public function loginactiveds () AS Boolean' Opens an Active Directory Object 'Using Specific Credentials.

'Defined LDAP binding string, the calling function ParseDomainName (DomainName) resolve domain names Dim strLDAP As String strLDAP = "LDAP: //" & ExchangeServerName & "/" & _ "cn =" & AccountNameVal & ", ou =" & ActiveDsOrganizationUnitNameVal & _ "& ParsedomainName (DomainName) DIM DSO AS ACTIVEDS.IADSOPENDSOBJECT DIM SOBJ AS ACTIVEDS.IADS

Try DSO = GetObject ("LDAP:") Sobj = DSO.OpendsObject (strldap, _ accountnameval, accountpassword, _ activeds .__miDL ___ midl_itf_ads_0000_0018.ads_secure_authentication)

Sobj = Nothing DSO = Nothing

Loginactiveds = true state = true catch 'msgbox ("User Name or Password Error, please re-enter.") LoginactiveDs = false state = false end end function' // end define function loginactiveds

'' // Private parsing domain name function parsedomainname '' // root domain name, COM NET, etc. '// main domain controller name, SUNRISE Microsoft, etc.' // subdomains such as: MSDN, etc. (MSDN.Microsoft .com) '// This function has 1 parameter, for domain name strings, here for the value of DomainName attribute' '' // Return LDAP string, such as "DC = Sunrise, DC = COM" Private function ParsedomainName (Byval IdomainName) As string) As string 'parsing domain name' DomainName Domain Name Properties DIM DomainDC AS String

Dim DomToKens' As String DomToKens = Split (Trim (IdomainName), ".", -1, 1) DomainDC = Join (DOMTOKENS, ", DC =") DomainDC = "DC =" & DomainDCPARSEDOMAINNAME = DomainDC END FUNCTION

'' Defined class UserMailService properties ExchangeServerName (Exchange DNS server name) Private ExchangeServerNameVal As String Public Property ExchangeServerName () As String Get '' ' Return ExchangeServerNameVal' Same As Prop1 = PropVal End Get Set ( Byval value as string) ExchangeeServerNameval = trim (value) End set End Property

'' Defined class UserMailService properties DomainName (DNS primary domain) Private DomainNameVal As String Public Property DomainName () As String Get Return DomainNameVal 'Same As Prop1 = PropVal End Get Set (ByVal Value As String) DomainNameVal = Trim (Value) End Set End Property

'' Attributes define the class UserMailService ExchangeFirstOrganizationName (Exchange Message storage system organization name) Private ExchangeFirstOrganizationNameVal As String Public Property ExchangeFirstOrganizationName () As String Get Return ExchangeFirstOrganizationNameVal End Get Set (ByVal Value As String) ExchangeFirstOrganizationNameVal = Trim (Value) End Set End Property

'' Defined class UserMailService properties ADUserDept (user's organizational unit OU) Private ActiveDsOrganizationUnitNameVal As String Public Property ActiveDsOrganizationUnitName () As String Get Return ActiveDsOrganizationUnitNameVal End Get Set (ByVal Value As String) ActiveDsOrganizationUnitNameVal = Trim (Value) End Set End Property '' UserMailService defined class attributes UserGroupName (user group added) Private UserGroupNameVal as String Public property UserGroupName () as String Get Return UserGroupNameVal End Get set (ByVal Value as String) UserGroupNameVal = Trim (Value) End set End property

'' Attributes define the class UserMailService the AccountName (user account name) Private AccountNameVal As String Public Property AccountName () As String Get Return AccountNameVal End Get Set (ByVal Value As String) AccountNameVal = Trim (Value) End Set End Property

'' Attributes define the class UserMailService AccountPassword (user password) Private AccountPasswordVal As String Public Property AccountPassword () As String Get Return AccountPasswordVal End Get Set (ByVal Value As String) AccountPasswordVal = Trim (Value) End Set End Property

'' Defined class UserMailService properties UserFirstName (user surname) Private UserFirstNameVal As String Public Property UserFirstName () As String Get Return UserFirstNameVal End Get Set (ByVal Value As String) UserFirstNameVal = Trim (Value) End Set End Property '' defined class UserMailService the property UserLastName (user name) Private UserLastNameVal As String Public property UserLastName () As String Get Return UserLastNameVal End Get Set (ByVal Value As String) UserLastNameVal = Trim (Value) End Set End property

'' Attributes define the class UserMailService UserMailBoxName (a mailbox name) Private UserMailBoxNameVal As String Public Property UserMailBoxName () As String Get Return UserMailBoxNameVal End Get Set (ByVal Value As String) UserMailBoxNameVal = Trim (Value) End Set End Property

'' Define the readOnLy attribute of class usermailService, "Create connection status) '' True (Created), false (Created) Private StateVal As Boolean Public Property State () AS Boolean Get Return StateVal End Get Set (Byval Value As Boolean ) Stateval = value End End Property End Class

Public Class DBaselogin

'// defined function logindbase' // function descriptoin '// This function gets the current login user information in the data table, using the DataSet binding database and 007User table,' // This function has 2 parameters, ilinkedsqlserver is public the return value of the function LinkedSqlServer SqlConnection, '// IPublicApplication is a common data structure PublicApplicationVal' // this function returns the queried DataSet, contains all the fields' // Begin define function LoginDBase public function LoginDBase (ByVal ILinkedSqlServer as SqlConnection, _ ByVal IPublicApplication As comm.publicapplicationvalvalVal) AS Dataset

DIM STRSQL AS STRING

DIM Objda As SqldataAdapter Dim Objds As New DataSet ()

'' // Query Condition is Characteristic Field strsql = "Select * from" & ipublicApplication.dbtable & _ "Where" & ipublicapplication.QueryfieldName & _ "= '" & ipublicapplication.queryfieldvale & "'"

Objda = new sqldataadapter (strsql, ilinkedsqlser) Objda.fill (Objds, "'" & ipublicapplication.dbtable & "" ")

Objda = Nothing

Logindbase = objds end function '// end define function logindbase

End Classend Namespace

转载请注明原文地址:https://www.9cbs.com/read-25880.html

New Post(0)